I'm currently working with Spatie roles and permissions library. I have multiple guards which are admin and web. My admin have permission to 'manage authentication' with guard_name = admin. When I try to run the syntax below it return true.
current_user()->hasPermissionTo('manage authentication', 'admin')
But when I use @can directives the span tag not appear.
@can('manage authentication')
<span>Hello</span>
@endcan
I tried this, but still the span tag is not appearing.
@can('manage authentication', 'admin')
<span>Hello</span>
@endcan
Am I doing it wrongly?
Update: I dont have any roles / permission related property and function inside my user model
@can not will work with multi guards
You can use this :
@if(auth('guard-name')->check() && auth('guard-name')->user()->can('permission-name'))
after that run :
php artisan cache:forget spatie.permission.cache
then :
php artisan cache:clear
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With