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

Update RoleBooleanGroup.php #19

Closed Ivana-C closed 2 years ago

Ivana-C commented 2 years ago

Fix issue - call to a member function can() on null

kiritokatklian commented 2 years ago

Fix issue - call to a member function can() on null

Hey @Ivana-C, thanks for the PR. I see that you've removed the filter on whether the signed in user has permission to view the role. This removes a feature that's been requested by a lot of other users instead of addressing the actual issue.

Auth::user() should not be null when a user has signed in to Nova. I'm not sure what your use case is, and why it's null in your case, but I'd be happy to help if you can provide more details.

Ivana-C commented 2 years ago

Hey, thanks for the quick response. You're right, and the package works perfectly on its own. The problem arises when I try to export users data using Laravel Nova Excel. It gives me that error even after excluding the Roles and Permissions columns. It doesn't happen on my local version but it does when uploading to server, which is why I tried to modify this code. But my attempted solution didn't actually fix it because now I'm getting this error:

Call to a member function can() on null {"exception":"[object] (Error(code: 0): Call to a member function can() on null at /var/www/html/vendor/kiritokatklian/nova-permission/src/PermissionBooleanGroup.php:30)

Any idea why this is happening?

Ivana-C commented 2 years ago

Nevermind, there is no session available in jobs so I have to pass the data manually, otherwise Auth::user() will always be null.