I want make register form by number, name, password with Laravel auth.
So I change username method in LoginController.php and validate method ,create method in RegisterController.php like following code.
But always show error
SQLSTATE[HY000]: General error: 1364 Field 'email' doesn't have a default value
LoginController
public function username()
{
return 'number';
}
RegisterController
protected function validator(array $data)
{
return Validator::make($data, [
'name' => ['required', 'string', 'max:255'],
'number' => ['required'],
'password' => ['required', 'string', 'min:8', 'confirmed'],
'password_confirmation' => ['required'],
]);
}
protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'number' => $data['number'],
'password' => Hash::make($data['password']),
]);
}
I spent 2day for find registration customize authentication but I only see login customize.
I finded only one about registration customize. But this page don't show solution.
https://laracasts.com/discuss/channels/laravel/user-registration-without-email?page=1
please help me.
Your User Model has
email
field that it:Go to your migrations
create_users_table
, and edit:to
But this is bad idea in my opinion, how will you identify those users later on? How will you let them reset their passwords?