Reputation: 1091
I am new to Laravel and learning just basic stuff. I am trying to create a new Route to create a user into database. So I created a Route like this -
Route::get('users/"create"', 'PagesController@create');
But I also have one Route for users trying to access their profile-
Route::get('users/{username}', 'PagesController@show');
Now when I try to access users/create it redirect me to show method instead of create method in controller. I am guessing this is because of generic nature of users/{username}. So my question is how to deal with such situation.
Upvotes: 1
Views: 291
Reputation: 60048
The order that you define routes is important. If you define your routes like this - in this order, it will work.
Route::get('users/create', 'PagesController@create');
Route::get('users/{username}', 'PagesController@show');
Note - I noticed you used 'users/"create"'
- that is an error - it should be 'users/create'
like in my example.
p.s. make sure you dont allow a user with the username called 'create' - or they will never be able to get to their profile page.
Upvotes: 2