Laravel 5.4 redirection to custom url after login

前端 未结 9 2192
悲哀的现实
悲哀的现实 2020-11-28 09:46

I am using Laravel Framework 5.4.10, and I am using the regular authentication that

php artisan make:auth

provides. I want to protect the

9条回答
  •  一向
    一向 (楼主)
    2020-11-28 10:15

    you can add method in LoginController add line use App\User; on Top, after this add method, it is work for me wkwkwkwkw , but you must add {{ csrf_field() }} on view admin and user

    protected function authenticated(Request $request, $user){
    
    $user=User::where('email',$request->input('email'))->pluck('jabatan');
    $c=" ".$user." ";
    $a=strcmp($c,' ["admin"] ');
    
    if ($a==0) {
        return redirect('admin');
    
    }else{
        return redirect('user');
    
    }}
    

提交回复
热议问题