Hello,
For some reason can isnt working on the user, but hasPermissionTo does work.
I prefer can because is uses cached permissions.
I have set the cache to database and there arent any cache rows created for the permissions.
Any ideas what could be wrong?
Kind regards,
Erwin
The permissions are registered at the gate in this function
It will put an exception in your log if for some reason it's unable to register those permissions.
Do you see a notice in your log? If not, try to determine if that function is being called.
I see that it's checking the database if there are any rows in the cache table.
select * from cache where key = 'mlmspatie.permission.cache' limit 1
And then it's trying to update a row. But there arent any rows in the cache table. So it keeps retrieving alle the permissions from the database.
I have checked the laravel.log file but that one is empty.
Could you try installing the package in a vanilla Laravel app and test if it works there?
Yep same for me...
Role Permissions:
access.backend
view.properties
create.properties
edit.properties
view.clients
create.clients
edit.clients
Direct Permissions: none
All Permissions:
access.backend
view.properties
create.properties
edit.properties
view.clients
create.clients
edit.clients
(at)can('view.sliders') => true
auth()->user()->hasPermissionTo('view.sliders') => false
This is the same caching issue as #231. You can use the following command to flush your cache and resolve the issue:
php artisan cache:forget spatie.permission.cache
Good luck!
Most helpful comment
This is the same caching issue as #231. You can use the following command to flush your cache and resolve the issue:
Good luck!