I'm new to Laravel world (using 5.0) and I'm learning how to route. I have this route
Route::get('users/{id}', 'UserController@showProfile');
and the UserController
public function showProfile($id)
{
return view('user.profile', ['user' => User::findOrFail($id)]);
}
everything works fine and the generated url is e.g. localhost:8000/users/1.
It is possible to mask this route, having instead something like localhost:8000/users/profile, making the query under the hood? Thank you all
The simplest thing to do would be to simply pull in the authenticated user:
Route::get('users/profile', 'UserController@showProfile');
public function showProfile()
{
return view('user.profile', ['user' => Auth::user()]);
}