Laravel version 7.0, I am using cviebrock/eloquent-sluggable package.
What I want is to put @
as prefix to the username.
I included Sluggable trait in User model and set like this.
public function sluggable()
{
return [
'username' => [
'source' => 'name',
'separator' => '',
'onUpdate' => true
]
];
}
Now what I want is https://mywebsite.com/@username
url shows user profile.
I think either we can put @
as prefix in sluggable package or we can detect it in laravel route.
Can anyone suggest me better way?
Thank you
I figured out the better solution.
I could add @ in laravel route easily.
Route::get('/@{username}', 'HomeController@user')->name('user.index');
We can save username without @ and put @ as prefix in laravel route.