1
I’m having trouble trying to access some routes that come from a Resource (products), She’s inside a group, follows my code:
Route::group([
'middleware' => ['web', 'auth'],
'prefix' => Config::get('shop.admin.url') . '/products',
'namespace' => 'LaraShop\Products\Http\Controllers',
'as' => 'products'
], function()
{
Route::resource('/', 'ProductsController');
});
Routes generated:
| POST | admin/products | store | LaraShop\Products\Http\Controllers\ProductsController@store | auth
| GET|HEAD | admin/products | index | LaraShop\Products\Http\Controllers\ProductsController@index | auth
| GET|HEAD | admin/products/create | create | LaraShop\Products\Http\Controllers\ProductsController@create | auth
| DELETE | admin/products/{} | destroy | LaraShop\Products\Http\Controllers\ProductsController@destroy | auth
| PUT|PATCH | admin/products/{} | update | LaraShop\Products\Http\Controllers\ProductsController@update | auth
| GET|HEAD | admin/products/{} | show | LaraShop\Products\Http\Controllers\ProductsController@show | auth
| GET|HEAD | admin/products/{}/edit | edit | LaraShop\Products\Http\Controllers\ProductsController@edit | auth
When accessing the route admin/products/1/edit
it returns error 404.
Someone’s been through it?
Your controller
LaraShop\Products\Http\Controllers\ProductsController
has the functionedit
? Try to put rumreturn 'ok';
to see if you’re coming to the Controller...– Evert
It’s not coming to the controller, but when removing the Source from the group, it works normally.
– Raank
And if you use
Route::get('/{id}/edit', 'ProductsController');
inside your group, does it work? If it works inside the group and doesn’t work outside, see if you’re logged in and if your controller is using auth...– Evert
The best way I could find was to use Resource outside and middleware inside the controller.
– Raank
is coming anyway
admin/products/{}
There’s nothing inside the keys???– novic