2016-08-28 10:05:21 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
|
|
|
|
class CheckAdminMiddleware
|
|
|
|
{
|
|
|
|
public function handle($request, \Closure $next)
|
|
|
|
{
|
|
|
|
$user = (new CheckAuthenticated)->handle($request, $next, true);
|
|
|
|
|
2016-08-29 23:08:09 +08:00
|
|
|
if ($user instanceof \Illuminate\Http\RedirectResponse) {
|
|
|
|
return $user;
|
|
|
|
}
|
|
|
|
|
2016-08-28 10:05:21 +08:00
|
|
|
if (!$user->is_admin) {
|
2016-08-29 23:08:09 +08:00
|
|
|
return redirect('user')->with('msg', '看起来你并不是管理员哦');
|
2016-08-28 10:05:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return $next($request);
|
|
|
|
}
|
|
|
|
}
|