Skip to content

Instantly share code, notes, and snippets.

@coreymcmahon
Last active August 29, 2015 14:15
Show Gist options
  • Save coreymcmahon/9b6e9e1e774b8e57c8ce to your computer and use it in GitHub Desktop.
Save coreymcmahon/9b6e9e1e774b8e57c8ce to your computer and use it in GitHub Desktop.
<?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