Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Webiondev123's avatar

Question on designing routes

Say I have a login homepage where every user lands after login. Now should I use the route generally or specific to every user like

route::get('home', HomeController@home);

OR

route::get('home/{id}', HomeController@home);
0 likes
1 reply
jcmargentina's avatar
Level 8

definetly the first one...

Route::get('home', HomeController@home);

inside your controller you should use

Auth::user()->id

or whatever logic you want to properly identify the current user in oder to do some specific procedures before you redirect him/her to the "homepage".

PD:

Of course I am asuming the controller already has the auth middleware assigned to it so you are sure that Auth::user() will always have a valid value.

GoodLuck, mark the answer as correct if helpfull.

Please or to participate in this conversation.