Additional question:
The slugs are dynamically created, which means you don't have prior knowledge about them. Therefore, you can't statically hardcode these into your route. Even if you could, there might be too many of them. So, I think the only way is to use wildcards to capture the navigated URI and then dynamically create the page.
First identify what the base URI for the slugs is: for example for the username of: <>b4dus3r name<>
(baduser name), you have generated bdusr-name
slug. You know that this slug is a username slug and you have decided to use the base URI as example.com/user/
. So to navigate to this user's profile you want: example.com/user/bdusr-name
.
Add this to your route file: Route::get('/user/{username},'UserController@show');
In your UserController
:
public function show($userSlug){
$user = \App\User::where('userslug','=',$userSlug)->get();
return view('user.show')->with('user',$user);
}
Here I am assuming that the user slug is stored in strings, not a foreign key, in the userslug
column in the users
table. In otherwords, you substitute the ID or what have you with the the slug.