Laravel resource calls wrong method

Viewed 341

I'm going nuts since hours with Laravel.

This is my web.php file:

// Admin
Route::group(['prefix' => 'admin', 'middleware' => ['auth', 'admin'], 'namespace' => 'Admin'], function() {

  Route::resource('cities', 'CitiesController');
  Route::resource('stores', 'StoresController');

});

I'm accessing http://localhost:3000/admin/cities/create and I get an error from the show method! Why the URL is calling the show method instead of create? And why if I remove the Route::resource and replace with verbose routes, it works? That's crazy.

enter image description here

UPDATE

My route:list:

|        | GET|HEAD  | admin                     | admin            | App\Http\Controllers\Admin\DashboardController@index                   | web,auth,admin |
|        | GET|HEAD  | admin/cities              | cities.index     | App\Http\Controllers\Admin\CityController@index                        | web,auth,admin |
|        | POST      | admin/cities              | cities.store     | App\Http\Controllers\Admin\CityController@store                        | web,auth,admin |
|        | GET|HEAD  | admin/cities/create       | cities.create    | App\Http\Controllers\Admin\CityController@create                       | web,auth,admin |
|        | GET|HEAD  | admin/cities/{city}       | cities.show      | App\Http\Controllers\Admin\CityController@show                         | web,auth,admin |
|        | PUT|PATCH | admin/cities/{city}       | cities.update    | App\Http\Controllers\Admin\CityController@update                       | web,auth,admin |
|        | DELETE    | admin/cities/{city}       | cities.destroy   | App\Http\Controllers\Admin\CityController@destroy                      | web,auth,admin |
|        | GET|HEAD  | admin/cities/{city}/edit  | cities.edit      | App\Http\Controllers\Admin\CityController@edit                         | web,auth,admin |
|        | GET|HEAD  | admin/stores              | stores.index     | App\Http\Controllers\Admin\StoreController@index                       | web,auth,admin |
|        | POST      | admin/stores              | stores.store     | App\Http\Controllers\Admin\StoreController@store                       | web,auth,admin |
|        | GET|HEAD  | admin/stores/create       | stores.create    | App\Http\Controllers\Admin\StoreController@create                      | web,auth,admin |
|        | GET|HEAD  | admin/stores/{store}      | stores.show      | App\Http\Controllers\Admin\StoreController@show                        | web,auth,admin |
|        | DELETE    | admin/stores/{store}      | stores.destroy   | App\Http\Controllers\Admin\StoreController@destroy                     | web,auth,admin |
|        | PUT|PATCH | admin/stores/{store}      | stores.update    | App\Http\Controllers\Admin\StoreController@update                      | web,auth,admin |
|        | GET|HEAD  | admin/stores/{store}/edit | stores.edit      | App\Http\Controllers\Admin\StoreController@edit                        | web,auth,admin |
1 Answers

Make your show store route like this:

Route::get('/store/{store}', 'StoresController@show')->name('stores.show');
Related