I want to register new users in my laravel application using the provided inbuilt functionality but also add two more fields: firstname and lastname. I am doing my registration in the admin area of the application and so i have a customized form that sends the data to the registration route. When I have an empty users table, I am able to add a new user to the database. When I use dd command I see the data sent from the client too. But when I try to add second user to the database, nothing happens. There are no errors displayed whatsoever. This time I try to use dd command and the application does not return anything.
To emphasize I do not wish to create another controller to handle this, but rather expand on the RegisterController that is already provided.
I need help to identify what I am doing wrong.
// In User model
protected $fillable = [
'firstname', 'lastname', 'email', 'password',
];
// get data from client in RegisterController.php
protected function validator(array $data)
{
return Validator::make($data, [
'firstname' => ['required', 'string', 'max:255'],
'lastname' => ['required', 'string', 'max:255'],
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
'password' => ['required', 'string', 'min:8', 'confirmed'],
]);
}
// save new user in RegisterController.php
protected function create(array $data)
{
dd($data);
return User::create([
'firstname' => $data['firstname'],
'lastname' => $data['lastname'],
'email' => $data['email'],
'password' => Hash::make($data['password']),
]);
}
// My form
<form method="POST" action="{{ route('register') }}">
@csrf
// code suppressed
</form>