No query results for model [App\Models\{model_name}] {method_name} #50214
-
In the past, I saw a tweet from Taylor where he talked about the 'best practices' of using the 7 'RESTful' methods. Since then, I have been applying this idea. However, now I have encountered this behavior. Look below:
Scenario 1: The application returned error ...
Route::apiResource('receipts', ReceiptController::class)->names('api.receipts');
Route::delete('receipts/destroy-multiple', [DeleteMultipleController::class, 'destroy'])
->name('api.delete-multiple.destroy');
... Scenario 2: The application works. ...
Route::delete('receipts/destroy-multiple', [DeleteMultipleController::class, 'destroy'])
->name('api.delete-multiple.destroy');
Route::apiResource('receipts', ReceiptController::class)->names('api.receipts');
... My question: Is this behavior correct? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
@ronaldaraujo Yes, this is expected behaviour. The |
Beta Was this translation helpful? Give feedback.
@ronaldaraujo Yes, this is expected behaviour. The
apiResource
method registers something like/receipts/{receipts}
which would match any/receipts/*
requests before your more explicit/receipts/destroy-multiple
route, therefore you need to register it before the API resource routes.