class Register extends FilamentRegister
{
public function register(): ?RegistrationResponse
{
return DB::transaction(function () {
$data = $this->form->getState();
// Create the User and associate with the Group
$user = User::create([
'name' => $data['name'],
'email' => $data['email'],
'phone' => $data['phone'], // Include the phone field
'password' => bcrypt($data['password'])
]);
// we need to somehow send the email here<-------
// Log the user in
auth()->login($user);
// Return the registration response
return app(RegistrationResponse::class);
});
}
protected function getForms(): array
{
return [
'form' => $this->form(
$this->makeForm()
->schema([
$this->getNameFormComponent(),
$this->getEmailFormComponent(),
$this->getPhoneFormComponent(),
$this->getPasswordFormComponent(),
$this->getPasswordConfirmationFormComponent(),
])
->statePath('data'),
),
];
}
protected function getPhoneFormComponent(): Component
{
return TextInput::make('phone')->required()->tel();
}
}