nova-bouncer icon indicating copy to clipboard operation
nova-bouncer copied to clipboard

Feature request: 'Applied to' field for Roles resource

Open Synchro opened this issue 2 years ago • 0 comments

I've been trying to figure out how to add a field that displays all the models that a Role has been applied to. I know it should be roughly the inverse of the MorphToMany used in my User resource:

            MorphToMany::make('Roles', 'roles', Role::class)->fields(
                static fn() => [
                    Text::make('Scope')
                        ->sortable()
                        ->rules('nullable', 'integer'),
                ]
            ),

However, I'm failing dismally at trying to see how to define a field for "things that this Role is applied to" since obviously it doesn't have a single class name that I can give it. I can see the records in the assigned_roles table that represent this linkage, but can't spot a corresponding relation in Bouncer to use in the MorphToMany.

I'm hoping that you have a better understanding of this!

Synchro avatar Dec 13 '22 08:12 Synchro