When we use resource route, we have the URL to be something like this for doing deletion.
DELETE http://localhost/user/1
How can we do deletion for more than one id in a single request?
Thank you.
When we use resource route, we have the URL to be something like this for doing deletion.
DELETE http://localhost/user/1
How can we do deletion for more than one id in a single request?
Thank you.
You'll have to create your own route for that:
Route::delete('users', 'UsersController@deleteMany');
Route::resource('users', 'UsersController');
Then you can send a DELETE request with the ids in the body:
DELETE /users
[1,2,3,4]
Then use that in your controller:
public function deleteMany()
{
User::whereIn('id', Request::json()->all())->delete();
}