Level 75
Add this to your User model
/**
* Get the route key for the model.
*
* @return string
*/
public function getRouteKeyName()
{
return 'slug';
}
Then just use
Route::resource('profile', 'ProfileController');
But if you want just one route then
Route::get('profile/{user:slug}', 'ProfileController@show');
public function show(User $user)
{
//
}
2 likes