Last active
June 4, 2016 07:41
-
-
Save Maras0830/ff620bf72fc1411278dced043d9d5d5a 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 Illuminate\Queue\InteractsWithQueue; | |
use Illuminate\Contracts\Queue\ShouldBeQueued; | |
use Maras\Contracts\LogsRepositoryInterface; | |
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