mardi 10 avril 2018

Laravel - Using Gate::allows for multiple objects

Is there a way to validate a policy for multiple elements or ids?

Let's say I have a $user object.

I can do: \Gate::allows('delete', $user).

What if I have a collection of User objects: $users.

Is there a way to do \Gate::allows('delete', $users)?

EDIT:

I have a route for deleting multiple entities.

Route::delete('/users', 'UsersController@deleteMultiple');

The payload is an array of ids.

['ids' => [1, 2, 3]]



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire