vyuldashev / nova-permission

A Laravel Nova tool for Spatie's laravel-permission library
https://novapackages.com/packages/vyuldashev/nova-permission
419 stars 217 forks source link

`Role` and `Permission` resources are not eager-loading relationships #132

Open chescos opened 4 years ago

chescos commented 4 years ago

Is it possible to add eager-loading for the resources?

sirikkoster commented 3 years ago

Any update on this?

xPand4B commented 3 years ago

One possible way:

You could extend the original Resource like following and add the $with property.

...
use Vyuldashev\NovaPermission\Role as BaseRole;

class Role extends BaseRole
{
    ...

    public static $with = [
        'permissions'
    ];

    ...
}

If you do so don't forget to define the new resource inside the NovaServiceProvider like this:

public function tools() :array
{
    return [
        ...
        NovaPermissionTool::make()
            ->roleResource( YourNewRoleResource::class ),
        ...
    ];
}