I write api for mobile, since I have more than one version, I don't want to copy-paste the same routes, hence I decided to do something like this:
Route::model('callRequestNote', CallRequestNote::class);
Route::group([
'prefix' => 'api/v{version}/mobile',
'where' => ['version' => '[1|2]'],
], function () {
Route::delete('/notes/{callRequestNote}', MobileNotesController::class . '@destroy');
// other duplicated routes
});
public function destroy(CallRequestNote $callRequestNote)
{
//
}
In this situation CallRequestNote
is not binded to route properly and I get exception:
Argument 1 passed to NotesController::index() must be an instance of CallRequestNote, string given
But when I don't use parameters in prefix, like this:
Route::group([
'prefix' => 'api/v1/mobile',
], function () {
Route::delete('/notes/{callRequestNote}', MobileNotesController::class . '@destroy');
});
Model is binded properly. Any ideas how to make it work?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire