Answer the question
In order to leave comments, you need to log in
How to redirect an authorized user at the route level?
Hey! I have a page on the site, index - /, and I want to have access to it only for non-registered users, how to implement the redirect "correctly"? Now it works like this for me, but as far as I know, these are crutches ... I would be glad if you explain what is wrong, thanks!
Route::get('/', function () {
if(Auth::check()){
return redirect()->route('home');
}else{
return view('index');
}
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question