2017-09-21 2 views
3

Ich bin seit Stunden mit Laravel verrückt.Laravel Ressource ruft falsche Methode

Das ist meine web.php Datei:

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

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

}); 

ich http://localhost:3000/admin/cities/create bin Zugriff und ich erhalte eine Fehlermeldung von der show Methode! Warum ruft die URL die show-Methode anstelle von create auf? Und warum, wenn ich die Route::resource entferne und durch ausführliche Routen ersetze, funktioniert es? Das ist verrückt.

enter image description here

UPDATE

Mein route:list:

|  | GET|HEAD | admin      | admin   | App\Http\Controllers\Admin\[email protected]     | web,auth,admin | 
|  | GET|HEAD | admin/cities    | cities.index  | App\Http\Controllers\Admin\[email protected]      | web,auth,admin | 
|  | POST  | admin/cities    | cities.store  | App\Http\Controllers\Admin\[email protected]      | web,auth,admin | 
|  | GET|HEAD | admin/cities/create  | cities.create | App\Http\Controllers\Admin\[email protected]      | web,auth,admin | 
|  | GET|HEAD | admin/cities/{city}  | cities.show  | App\Http\Controllers\Admin\[email protected]       | web,auth,admin | 
|  | PUT|PATCH | admin/cities/{city}  | cities.update | App\Http\Controllers\Admin\[email protected]      | web,auth,admin | 
|  | DELETE | admin/cities/{city}  | cities.destroy | App\Http\Controllers\Admin\[email protected]      | web,auth,admin | 
|  | GET|HEAD | admin/cities/{city}/edit | cities.edit  | App\Http\Controllers\Admin\[email protected]       | web,auth,admin | 
|  | GET|HEAD | admin/stores    | stores.index  | App\Http\Controllers\Admin\[email protected]      | web,auth,admin | 
|  | POST  | admin/stores    | stores.store  | App\Http\Controllers\Admin\[email protected]      | web,auth,admin | 
|  | GET|HEAD | admin/stores/create  | stores.create | App\Http\Controllers\Admin\[email protected]      | web,auth,admin | 
|  | GET|HEAD | admin/stores/{store}  | stores.show  | App\Http\Controllers\Admin\[email protected]      | web,auth,admin | 
|  | DELETE | admin/stores/{store}  | stores.destroy | App\Http\Controllers\Admin\[email protected]      | web,auth,admin | 
|  | PUT|PATCH | admin/stores/{store}  | stores.update | App\Http\Controllers\Admin\[email protected]      | web,auth,admin | 
|  | GET|HEAD | admin/stores/{store}/edit | stores.edit  | App\Http\Controllers\Admin\[email protected]      | web,auth,admin | 
+1

Können Sie den (relevanten Teil) teilen die Ausgabe von 'php artisan route: l ist' und der Create Route Handler? – apokryfos

+0

Sie machen Anfrage auf dieser URL http: // localhost: 3000/admin/cities/create –

+0

Sie haben Route 'admin/cities/create' und' admin/cities/{city} ', die Mehrdeutigkeit für Route Controller erstellt als 'create' ist ein Argument für' {city} '. Und deshalb Aufruf an 'show' Methode –

Antwort

-1

Machen Sie Ihre Show speichern Route wie folgt aus:

Route::get('/store/{store}', '[email protected]')->name('stores.show'); 
+0

Ich möchte '/ stores /' behalten. –