On/off toggle based on relationship? (Spatie/Laravel Permission)
I have this toggle to on/off certain permissions on the Edit User resource. How do I make that work with permissions stored in another table using Laravel Permission by Spatie?
Basically a name in the permissions table could be
'view this'
with id = 9
for example. I need t check if it exists for this userID and turn the toggle on/off based on that.
If exists and I turn off the toggle it should delete and vice versa.2 Replies
Tried messing with
loadStateFromRelationshipsUsing
but cant find any documentation about it
Anyone?Something like Toggle::make('user.role.permission')->label('Test'); But that wouldnt solve your problem completly. I would look in the source code of filament shield, in that plugin they have toggles based on permissions. Should be able to find how to do it there..?