Reputation: 957
I'm experiencing routing confusion in laravel 4.
Route::group(['prefix' => 'myProfile', 'before' => 'auth|inGroup:Model|isMe'], function()
{
Route::get('/{username}', function(){
echo 'hello';
});
});
Route::get('/{username}', [
'as' => 'show-profile',
'uses' => 'ProfileController@index'
]);
When i write to address bar domain.app/myProfile it runs second route and runs ProfileController@index...
Thanks.
Upvotes: 0
Views: 39
Reputation: 5791
Breaking down your routes:
1)
Route::get('/{username}', [
'as' => 'show-profile',
'uses' => 'ProfileController@index'
]);
Use /example
URI to access the above route.
2)
Route::group(['prefix' => 'myProfile', 'before' =>'auth|inGroup:Model|isMe'], function()
{
Route::get('/{username}', function(){
echo 'hello';
});
});
Use /myProfile/example
URI to access the above route.
Your application is working as expected.
Upvotes: 1
Reputation: 343
Looks like correct behaviour. To access first route you would have to type something like domain.app/myProfile/FooUser
. You didn't specify /
route in myProfile route group, so it cannot match it and uses second one.
Upvotes: 2