I want to customize Laravel Auth. I want to distinguish between admins and users. In the default users table, I added column role with two options: admin and user. According to the manual, I'm defining redirectTo method.
class LoginController extends Controller { use AuthenticatesUsers; /** * Where to redirect users after login. */ /** * Create a new controller instance. * * @return void */ public function __construct() { $this->middleware('guest')->except('logout'); } protected function redirectTo() { if (Auth::user()->role == 'admin') { return 'admin/home'; } else { return '/main'; } } protected function show_admin_homepage() { return view('auth.admin_h'); } protected function show_user_homepage() { return view('auth.user_h'); } } Routes
Route::get('main', 'Auth\LoginController@show_user_homepage')->name('show_user_homepage'); Route::get('admin/home', 'Auth\LoginController@show_admin_homepage')->name('show_admin_homepage'); The problem is that when I'm logging as a user or as admin, I'm always redirecting to default laravel home view. What I'm doing wrong?