Created
January 28, 2017 14:45
-
-
Save yooouuri/f5d5992a04ebb6f9494196e8c928c8a5 to your computer and use it in GitHub Desktop.
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 | |
| namespace App\Http\Middleware; | |
| use App\User; | |
| use Closure; | |
| use Illuminate\Support\Facades\Auth; | |
| class CheckAdmin | |
| { | |
| /** | |
| * Handle an incoming request. | |
| * | |
| * @param \Illuminate\Http\Request $request | |
| * @param \Closure $next | |
| * @return mixed | |
| */ | |
| public function handle($request, Closure $next) | |
| { | |
| if (Auth::check()) { | |
| /** @var User $user */ | |
| $user = Auth::user(); | |
| if ($user->isAdmin()) { | |
| return $next($request); | |
| } | |
| } | |
| return response() | |
| ->redirectToRoute('admin'); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment