Reputation: 1353
I have a database with two tables: table CATEGORIES has an id that is the fk of table PRODUCTS. When I want to delete a category, and a record in table products has associated that category id, laravel return a 405 error and i cannot access to destroy method. How can I avoid 405 error and access to destroy method?
Here's my route config:
$api = app('Dingo\Api\Routing\Router');
$api->version('v1',['middleware' => ['api']], function($api){
$api->resource('categories', 'App\Http\Controllers\CategoriesController');
$api->resource('products', 'App\Http\Controllers\ProductsController');
$api->get('categories/{id}/products', 'App\Http\Controllers\CategoriesController@products');
});
EDIT
If the category isn't associated with any product, delete method doesn't throw any error so I guess it isn't a route problem
Upvotes: 0
Views: 921
Reputation: 12460
Laravel only returns HTTP 405 if a route exists but not for that method. I'm not entirely familiar with Dingo, but run php artisan route:list
to check that the route you're trying to use has been registered for a DELETE request.
Upvotes: 1