i have register auth page and i need to do action like

$user = Auth()->user(); $user->assignRole('admin'); in this page class Register extends BaseRegister { protected function getForms(): array { return [ 'form' => $this->form( $this->makeForm() ->schema([ $this->getNameFormComponent(), $this->getEmailFormComponent(), $this->getPasswordFormComponent(), $this->getPasswordConfirmationFormComponent(), ]) ->statePath('data'), ), ]; } }
5 Replies
Ahmed Ali
Ahmed Ali5mo ago
i am use spatie and i need when user register via filament register page assign to it default role any help? why no someone help me to take register page in filament give the user default role but take in consider i have function to give role not just role field in user model because i used spatie for that,
Tobias Platen
Tobias Platen5mo ago
maybe something like this:
public function register(): ?RegistrationResponse
{
$return = parent::register();
Auth::user()->assignRole('admin');
return $return;
}
public function register(): ?RegistrationResponse
{
$return = parent::register();
Auth::user()->assignRole('admin');
return $return;
}
mohamedali5738
mohamedali57385mo ago
protected function getRoleFormComponent(): Component { return Hidden::make('role')->default('user')->required(); } تقصد كدة يا احمد ولا ايه ؟
Tobias Platen
Tobias Platen5mo ago
From Docu: Please be aware that the value of this field is still editable by the user if they decide to use the browser's developer tools. You should not use this component to store sensitive or read-only information.
mohamedali5738
mohamedali57385mo ago
ok thanks , i have one question i want to apply multi-lang on table and i decide to make two table one orginal table and other for translate how to apply this in filament or what is the idea for this case ?