在Laravel

时间:2017-09-29 09:12:47

标签: laravel-5

登录admin时,页面重定向但是 ' 页面未正确重定向'消息显示。请帮帮我

  

中间件 - IsAdmin.php

    public function handle($request, Closure $next)
    {

         if (Auth::user()->role_id == 1)
        {
            return redirect ('/administrator');
        }

               return $next($request);
    }
  

web.php

Route::group(['prefix'=>'administrator','as' => 'admin.','middleware' => ['auth'],'middleware' => 'isAdmin'], function(){

    Route::get('/','AdminController@index');

    Route::resource('user','AdminController');

    Route::resource('card','AdminCardController');

});

Thanx in advanced ..

1 个答案:

答案 0 :(得分:1)

确保在karnel中注册middlware并尝试以下代码:

Route::prefix('admin')->group(function () {
 Route::middleware(['auth', 'IsAdmin'])->group(function () {
   // Your routes 
 });
});