Laravel Make: Middleware
php artisan make:middleware AdminMiddleware
Different Dogfish
php artisan make:middleware AdminMiddleware
public function handle($request, Closure $next)
{
if ($request->user()->type != 'A')
{
return redirect('home');
}
return $next($request);
}
Route::group(['middleware' => 'App\Http\Middleware\AdminMiddleware'], function()
{
Route::get ('/admin', ['uses' => 'AdminController@index', 'before' => 'admin']);
});
if (Auth::user()->is_admin != 1) {...}