I have this schema for my REST API urls:
Verb Url Method
GET /tasks findAll
GET /tasks/{id} findOne
POST /tasks create
PUT /tasks/{id} update
DELETE /tasks/{id} deleteOne
DELETE /tasks deleteAll
Is there a way for override the default method of Route Resource Laravel built-in methods (store,create,edit etc...) and create with a single line my custom route associated with my controller?
For example:
Route::resource('/tasks', 'TasksController');
Instead of:
Route::get('/tasks', 'TasksController@findAll');
Route::get('/tasks/{id}', 'TasksController@findOne');
Route::post('/tasks', 'TasksController@create');
Route::put('/tasks/{id}', 'TasksController@update');
Route::delete('/tasks', 'TasksController@deleteAll');
Route::delete('/tasks/{id}', 'TasksController@deleteOne');
addResourceData()
and add the methods inprotected $resourceDefaults = [....]
. Also remove unwanted in$resourceDefaults
. – Thomas Van der Veen