Skip to content

Instantly share code, notes, and snippets.

@Maras0830
Last active June 4, 2016 07:42
Show Gist options
  • Save Maras0830/5aec56cab9ba621f98b6294de145b747 to your computer and use it in GitHub Desktop.
Save Maras0830/5aec56cab9ba621f98b6294de145b747 to your computer and use it in GitHub Desktop.
Member middleware after login.
<?php
namespace App\Http\Middleware\Login;
use Closure;
use Carbon;
use Maras0830\Repository\LogsRepository;
class InsertLogs
{
protected $logsRepository;
/**
* Create the middleware.
* @param LogsRepository $logsRepository
* @return void
*/
public function __construct(LogsRepository $logsRepository)
{
$this->logsRepository = $logsRepository;
}
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$response = $next($request);
// 執行登入後的記錄
if (Auth::check())
$this->logsRepository->insertMemberLoginLogs(Auth::user(), $request->ip(), Carbon::NOW());
return $response;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment