Last active
June 4, 2016 07:42
-
-
Save Maras0830/5aec56cab9ba621f98b6294de145b747 to your computer and use it in GitHub Desktop.
Member middleware after login.
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\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