I am trying to customize the laravel auth registration. And I have added father name field in table and form. But father name field is not required. I added this field in registercontroller.php and in User model also. And then, if submit the form with all fields then data inserts successfully, But if I submit the form without father name field (which is not required), then error comes: f_name filed can not be null.
If I remove f_name from fillable then f_name is not saving.
Method in RegisterController.php is:
protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'f_name' => $data['f_name'],
'password' => bcrypt($data['password']),
]);
}
User.php is:
protected $fillable = [
'name', 'email', 'f_name' , 'password',
];