kiritokatklian / nova-permission

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

Undefined array key "guard_name" #26

Closed Livijn closed 1 year ago

Livijn commented 1 year ago

When viewing a Role or Permission I get this exception:

Undefined array key "guard_name" {"userId":1,"exception":"[object] (ErrorException(code: 0): Undefined array key \"guard_name\" at /Users/fredrik/Documents/code/xxx/vendor/spatie/laravel-permission/src/Models/Role.php:73)

The error is coming from the "model"-relation and I can see that the Roles guard_name is set: print screen

Also, the $attributes is empty when dumping info("model", [$this->attributes]); it the users()-function on the Role model.

kiritokatklian commented 1 year ago

@Livijn I can't seem to be able to reproduce your issue. I logged $this->attributes in the Role model and got this:

[2022-10-22 11:10:02] local.INFO: model [{"id":1,"name":"superAdmin","display_name":"Super Administrator","guard_name":"web","created_at":"2021-05-18 23:34:33","updated_at":"2022-04-24 10:59:14"}]

I'd reinstall both packages and run artisan cache:clear to see if that helps. Alternatively, you can open an issue over at the main spatie/laravel-permission repo, because this sounds like an issue caused by to the recent PR #2219.

Livijn commented 1 year ago

Removing and then reinstalling the packages actually fixed it. Thanks for your time!