Search code examples
phplaravellaravel-permission

Laravel Spatie can() always returning false but hasPermissionTo() works


I'm trying to create permissions and roles for users in a Laravel Project using Spatie creating permissions and assigning them to roles and then users works fine, but when checking for permission using can it always returns false even when the permission is assigned to the role, but hasPermissionTo works as expected.


Solution

  • as we discussed on the comments sometimes you have to clear your cache try running

    php artisan optimize:clear