thedevdojo / voyager

Voyager - The Missing Laravel Admin
https://voyager.devdojo.com
MIT License
11.78k stars 2.67k forks source link

Policy on delete return empty object #3627

Open tommiekn opened 6 years ago

tommiekn commented 6 years ago

Version information

Description

Hi, I am not entirely sure this is related directly to Voyager and not Laravel itself but i am having issues in using a Policy only the delete method.

I can successfully filter users with things like this:

public function update(User $user, Action $action) { return $user->id === $action->user_id; }

However, the delete method doesn't work, if i try to print out "$action->user_id" and gives NULL. As the delete button starts on Voyager interface wanted to check if is something related to this or if i missed anything. Policies works well for every method except delete, all delete methods doesnt return the object to delete apparently.

Thanks

emptynick commented 5 years ago

https://github.com/the-control-group/voyager/blob/1e3e845745a1ec7406300c1632af56655361c0f7/src/Http/Controllers/VoyagerBaseController.php#L346 We pass the model-name because bulk-delete would force us to call authorize too many times.