Skip to content

Instantly share code, notes, and snippets.

@Maras0830
Last active June 4, 2016 07:41
Show Gist options
  • Save Maras0830/ff620bf72fc1411278dced043d9d5d5a to your computer and use it in GitHub Desktop.
Save Maras0830/ff620bf72fc1411278dced043d9d5d5a to your computer and use it in GitHub Desktop.
Member Login event handler.
<?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