Last active
August 29, 2015 14:15
-
-
Save coreymcmahon/9b6e9e1e774b8e57c8ce to your computer and use it in GitHub Desktop.
Example of Laravel 5 Middleware - http://slashnode.com/definitive-laravel-4-to-laravel-5-migration-guide/
This file contains hidden or 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 | |
/** in app/Http/Middleware/GuestMiddleware.php */ | |
class GuestMiddleware implements Middleware | |
{ | |
public function handle($request, Closure $next) | |
{ | |
if (\Auth::check()) { | |
return new RedirectResponse(url('/')); | |
} | |
return $next($request); | |
} | |
} | |
/** in app/Http/Kernel.php */ | |
/** ...etc */ | |
protected $routeMiddleware = [ | |
'guest' => 'App\Http\Middleware\GuestMiddleware', | |
]; | |
/** ...etc */ | |
/** in app/Http/routes.php */ | |
get('auth/login', ['middleware' => 'guest' 'uses' => 'AuthController@getLogin']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment