Created
August 31, 2016 13:56
-
-
Save nissicreative/41e1f8ba5da9975ca0cd997dbfa01b2a to your computer and use it in GitHub Desktop.
Laravel Admin Middleware
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; | |
use Auth; | |
use Closure; | |
class Admin | |
{ | |
/** | |
* Handle an incoming request. | |
* | |
* @param \Illuminate\Http\Request $request | |
* @param \Closure $next | |
* @return mixed | |
*/ | |
public function handle($request, Closure $next) | |
{ | |
if (Auth::check() && Auth::user()->isAdmin()) { | |
return $next($request); | |
} | |
abort(403); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment