Level 73
You are using named routes in your redirect. Do you have those named routes defined in your web.php file?
Route::get('/admin/dashboard', 'SomeController@dashboard')->name('admin.dashboard');
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
This is mine RedirectifAuthenticated.php code
When i am Manually going to localhost/admin/dashbaord then its accessible after logging in if i remove this code but when i am writting this code then its not accessible
public function handle($request, Closure $next, $guard = null)
{
if (Auth::guard($guard)->check() && Auth::user()->role->id == 1) {
return redirect()->route('admin.dashboard');
}elseif(Auth::guard($guard)->check() && Auth::user()->role->id == 2){
return redirect()->route('user.dashboard');
}else
{
return $next($request);
}
}
} I have this code its gaving Error that route admin.dashboard not defined if i Mnaually go to route admin.dashbaord then its Accessible
l
Please or to participate in this conversation.