Last active
June 4, 2016 07:46
-
-
Save Maras0830/72b4e858fff5e72abf97d688ab560883 to your computer and use it in GitHub Desktop.
Member login event handler.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php namespace App\Handlers\Events; | |
use App\Events\MemberLoginEvent; | |
use Maras\Contracts\LogsRepositoryInterface; | |
use Auth; | |
use Carbon\Carbon; | |
class MemberLoginEventHandler | |
{ | |
protected $logsRepository; | |
/** | |
* Create the event handler. | |
* @param LogsRepository $logsRepository | |
* @return void | |
*/ | |
public function __construct(LogsRepositoryInterface $logsRepository) | |
{ | |
$this->logsRepository = $logsRepository; | |
} | |
/** | |
* Handle the event. | |
* | |
* @param MemberLoginEvent $event | |
* @return void | |
*/ | |
public function handle(MemberLoginEvent $event) | |
{ | |
執行登入後的記錄 這裏為了範例起見 先將它註解掉 | |
if (Auth::check()) | |
$this->logsRepository->insertMemberLoginLogs(Auth::user(), $event->request->ip(), Carbon::NOW()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment