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 by adding /register to the url. The user must provide the name, email, the user type - by default Admin, Author or Member - and a password.

For logging in, the user can press the Laravel Login As button in the top navbar or by simply adding /login in the url.

The App\Http\Controllers\Auth\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']),
                                    'slug' => $data['slug'],
                                ]);
                            }
                        

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'],
                                ]);
                            }