Beartropy Permissions
Permissions Not Persisting
If permissions are not being saved, ensure your User model uses the HasRoles trait:
1<?php 2 3namespace App\Models; 4 5use Illuminate\Foundation\Auth\User as Authenticatable; 6use Spatie\Permission\Traits\HasRoles; 7 8class User extends Authenticatable 9{10 use HasRoles;11 12 // ...13}
Views Not Updating After Changes
If views are not updating, clear the view cache and Livewire discovery:
1php artisan view:clear2php artisan livewire:discover
Translations Not Working
Make sure your locale is set correctly in config/app.php. If using published translations, ensure they exist at lang/vendor/beartropy-permissions/.
1// config/app.php2'locale' => 'es', // or 'en'
Cache Issues
If roles or permissions don't update immediately, clear the Spatie permission cache.
Clear Cache in Code
You can clear the cache programmatically:
1// In your code2app()[\Spatie\Permission\PermissionRegistrar::class]->forgetCachedPermissions();
Clear Cache via Artisan
Or you can use the Artisan command:
1php artisan permission:cache-reset
Custom User Model Location
If your User model is in a different namespace, update the configuration:
1// config/beartropy-permissions.php2'user_model' => \App\Domain\Users\Models\User::class,
Multiple Guards
If you use multiple authentication guards, configure them:
1// config/beartropy-permissions.php2'guards' => ['web', 'api', 'admin'],3'default_guard' => 'web',