You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using spatie/laravel-permissions with filament shield. But I am trying to use assignRole on the user model but it is not adding it in to the database and not updating and I have no clue why.
I have installed everything correctly I believe and all the roles exist.
And even in this listener I am trying add the default role when the user registers, but is not working and I have made sure this listener is registered and working with logging but nothing.
Even when I change default to a role that doesn't exist like asd it comes with an error, but when it stays as default it doesn't throw and error but it doesnt add the role to the user.
namespaceApp\Models;
useFilament\Models\Contracts\FilamentUser;
useFilament\Panel;
useIlluminate\Contracts\Auth\MustVerifyEmail;
useIlluminate\Database\Eloquent\Factories\HasFactory;
useIlluminate\Foundation\Auth\UserasAuthenticatable;
useIlluminate\Notifications\Notifiable;
useLaravel\Sanctum\HasApiTokens;
useSpatie\Permission\Traits\HasRoles;
class User extends Authenticatable implements FilamentUser, MustVerifyEmail
{
use HasApiTokens;
use HasFactory;
use Notifiable;
use HasRoles;
/** * The attributes that are mass assignable. * * @var array<int, string> */protected$fillable = [
'name',
'email',
'password',
'email_verified_at',
];
/** * The attributes that should be hidden for serialization. * * @var array<int, string> */protected$hidden = [
'password',
'remember_token',
];
/** * The attributes that should be cast. * * @var array<string, string> */protected$casts = [
'email_verified_at' => 'datetime',
'password' => 'hashed',
];
/** * Get the points requests submitted by the user. */publicfunctionrequests()
{
return$this->hasMany(PointsRequest::class, 'submitted_by');
}
publicfunctioncanAccessPanel(Panel$panel): bool
{
returntrue;
}
}
find the two files attached for my configuration files and also any seeder or migrations you might need:
additionally I am using stancl tenancy, but this shouldn't make a difference to assign role I believe, because filament when adding in through the relations feature they have works perfectly fine.
it also works fine when i do it with tinker.
Please any help would be appreciated on this matter.
The text was updated successfully, but these errors were encountered:
Hi All,
I am using spatie/laravel-permissions with filament shield. But I am trying to use assignRole on the user model but it is not adding it in to the database and not updating and I have no clue why.
I have installed everything correctly I believe and all the roles exist.
^^^ here I am trying to use assignRole.
And even in this listener I am trying add the default role when the user registers, but is not working and I have made sure this listener is registered and working with logging but nothing.
Even when I change
default
to a role that doesn't exist likeasd
it comes with an error, but when it stays asdefault
it doesn't throw and error but it doesnt add the role to the user.my user model:
find the two files attached for my configuration files and also any seeder or migrations you might need:
additionally I am using stancl tenancy, but this shouldn't make a difference to assign role I believe, because filament when adding in through the relations feature they have works perfectly fine.
it also works fine when i do it with tinker.
Please any help would be appreciated on this matter.
The text was updated successfully, but these errors were encountered: