JosephSilber / bouncer

Laravel Eloquent roles and abilities.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Check if a role owns a model

obrunsmann opened this issue · comments

To implement a settings UI it is necessary to find out if a role can own or manage a model. So I'd suggest a method like

$role->canOwn(Task::class);

$role->canManage(Task::class);

The way to handle it in the UI would be to have a list of actual Ability instances. For example:

$available = Bouncer::ability()->pluck('title', 'id');
$granted = $role->getAbilities();

And then have the user toggle those directly.