davide-casiraghi /
laravel-cards
| 1 | <?php |
||
| 2 | |||
| 3 | namespace DavideCasiraghi\LaravelCards\Http\Middleware; |
||
| 4 | |||
| 5 | use Closure; |
||
| 6 | |||
| 7 | class Admin |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * Handle an incoming request. |
||
| 11 | * |
||
| 12 | * @param \Illuminate\Http\Request $request |
||
| 13 | * @param \Closure $next |
||
| 14 | * @return mixed |
||
| 15 | */ |
||
| 16 | public function handle($request, Closure $next) |
||
| 17 | { |
||
| 18 | $user = \Auth::user(); |
||
| 19 | |||
| 20 | // If user is not logged |
||
| 21 | if (! $user) { |
||
| 22 | return redirect('/')->with('message', 'You have not admin access'); |
||
| 23 | } |
||
| 24 | |||
| 25 | // If user is logged and admin/superadmin |
||
| 26 | //if (($user->isAdmin() || $user->isSuperAdmin()) == 1) { |
||
| 27 | if (($user->group == 2) || ($user->group == 1)) { |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 28 | return $next($request); |
||
| 29 | } |
||
| 30 | |||
| 31 | // Return to homepage if user il logged but not admin |
||
| 32 | return redirect('/')->with('message', 'You have not admin access'); |
||
| 33 | } |
||
| 34 | } |
||
| 35 |