samedi 4 août 2018

Laravel 5.6 Laravel authentication registers users with empty fields

I've been trying to solve this problem but can't figure out why it won't 'behave'.

I modified the data fields of Laravel 5.6 application's authentication but the fields keep saving empty fields in the database.

In resources/views/auth/register.blade.php: I have fields for 'firstname', 'surname', 'webaddress', 'sitecategory', 'email' and 'password'.

In app/Http/Controllers/Auth/RegisterController.php: protected function validator(array $data) { return Validator::make($data, [ 'firstname' => 'required|string|max:50', 'surname' => 'required|string|max:50', 'webaddress' => 'required|string|max:50', 'sitecategory' => 'required|string|max:30', 'email' => 'required|string|email|max:255|unique:users', 'password' => 'required|string|min:6|confirmed', ]); }

protected function create(array $data)
{
    return User::create([
        'firstname' => $data['firstname'],
        'surname' => $data['surname'],
        'webaddress' => $data['webaddress'],
        'sitecategory' => $data['sitecategory'],
        'email' => $data['email'],
        'password' => bcrypt($data['password']),
    ]);
}    


In app/User.php:
protected $fillable = [
    'firstname', 'surname', 'webaddress', 'sitecategory', 'email', 'password',
];

protected $hidden = [
    'password', 'remember_token',
];



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire