The seeder file is how abilities and permissions are applied to roles.
In the policy file I use $user->can()
to check if an user has an ability.
Each policy was loaded in a controller with $this->authorizeResource(ClientPolicy::class)
in the constructor.
Using this pattern lead to a Maximum function nesting level of '500' reached, aborting!
error.
Create a BouncerProvider
and move all the Bouncer::ownedVia()
calls to it's boot()
method.
Forget about the Policy
files.
At the top of each controller, add a __constructor()
which calls $this->authoriseResource(Client::class)
.
That's right, pass the Client
class and not the ClientPolicy
. Why does this work? I don't know yet, but it does.