Register

A new account can be created by a user with the help of the Create a new account button from the login page or the Register button from the top navabar. The user must provide the name, email, the user type - by default Admin, Author or Member - and a password.

The App\Http\Controllers\RegisterController handles the user's registration.


                    protected function create(array $data)
                    {
                        return User::create([
                            'name' => $data['name'],
                            'email' => $data['email'],
                            'role_id' => $data['user_type'],
                            'password' => Hash::make($data['password']),
                    }                
                

The data introduced by the user is validated because the account needs a valid email address and the password and password confirmation to match.


                    protected function validator(array $data)
                    {
                        return Validator::make($data, [
                            'name' => ['required', 'string', 'max:255'],
                            'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
                            'user_type' => ['required'],
                            'password' => ['required', 'string', 'min:6', 'confirmed'],
                        ]);
                    }