As-level routes to redirect the authorized user?

Hi! I have on the website page, indices - / and I want it to be access to only registered users, how to implement forwarding? Now I have it running here, but to my knowledge it's the crutches... I'll be glad if you explain what's wrong, thanks!

Route::get('/', function () {
if(Auth::check()){
 return redirect()->route('home');
}else{
 return view('index');
}
});


PS using the default authorization module
June 3rd 19 at 19:24
1 answer
June 3rd 19 at 19:26
Solution

Find more questions by tags Laravel