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