I am working on building a front-end for managing users / roles / permissions with the Spatie > Permissions package in the backend.
A feature I am seeking to implement is selecting a Permission and having this selection then display all Users having the selected permission.
Using php artisan tinker
, I can use the statement:
Spatie\Permission\Model\Permission::with("roles.users")->find(59);
, with 59
representing the permission->id in question, and the appropriate results are returned.
My problem is that when I take this code to php and I seek to dd((Permission::with('roles.users')->find(59));
I receive a Error
Class name must be a valid object or a string error.
Removing the nested relationship using dd((Permission::with('roles')->find(59));
is treated appropriately by Laravel. However I want access to the Users that have the specified permission.
In short, the nested eager loading seems to be failing, dependent entirely on whether the code is in Laravel or Tinker.
I am using php v7.3.25 and Laravel 8.22.1
Thanks for any help.