user4748790
user4748790

Reputation:

Route is not defined after updating laravel 5.1.8 to 5.1.24

I updated my laravel installation with the composer update and i get this error.

Route [categoryid] not defined

The strange thing is that, before the update, it worked just fine. My routes.php file looks like this:

Route::group(['prefix'=>'category'], function () {

    Route::get('mobilephones', [
        'as'=>'mobilephones',
        'uses'=>'PhoneController@getShow'
    ]);

    Route::get('{categoryid}', [
        'as'=>'categoryid',
        'uses'=>'CategoryController@one'
    ]);

    Route::get('{categoryid}', [
        'as'=>'computerscategoryid',
        'uses'=>'CategoryController@one'
    ]);      
});

and i am calling the route with this html code

<li><a href="{{route('categoryid',['argument'])}}">Argument</a></li>

Everything used to work so is anyone aware of a change in the Group route files after 5.1.8?

Upvotes: 0

Views: 113

Answers (1)

Thomas Kim
Thomas Kim

Reputation: 15911

As a general rule, always run php artisan route:list to see the compiled list of your routes.

You have two routes that do the exact same thing:

Route::get('{categoryid}', [
    'as'=>'categoryid',
    'uses'=>'CategoryController@one'
]);

Route::get('{categoryid}', [
    'as'=>'computerscategoryid',
    'uses'=>'CategoryController@one'
]);

They accept the same argument. They get sent to the same controller action. The only difference is that they have different route names. One of them (the second one) is most likely overriding the other. I would suggest removing the second one - computerscategoryid - because I can't see a purpose in having both of them.

Upvotes: 1

Related Questions