-
-
Notifications
You must be signed in to change notification settings - Fork 31
Closed
Description
Laravel Rest Api Version
2.14.2
Laravel Version
12.20.0
PHP Version
8.3.7
Database Driver & Version
No response
Description
When you want to delete multiple items, if one of the items is not authorised for deletion, the query returns an error, but the previous items in the query are still deleted.
Surely it would be possible to set up a transaction?
Steps To Reproduce
- Create a model with at least 3 elements
- Create a policy that doesn't permit to delete the element with id 2
<?php
namespace App\Policies;
use App\Models\Car;
class CarPolicy
{
public function delete(User $user, Car $car): bool
{
if ($car->id === 2)
return false;
else
return true;
}
}- Try to delete the elements 1, 2 and 3 using REST API
URL : {{api}}/cars
Method : DELETE
{
"resources" : [1, 2, 3]
}
The answer will be that it is forbidden, but the car with id 1 has been deleted well. It seems it iterates for each deletion until there is a problem, where the process stops.
Metadata
Metadata
Assignees
Labels
No labels