3 namespace App\Http\Controllers\Auth;
5 use App\Http\Controllers\Controller;
7 use App\Providers\RouteServiceProvider;
8 use Illuminate\Auth\Events\Registered;
9 use Illuminate\Http\Request;
10 use Illuminate\Support\Facades\Auth;
11 use Illuminate\Support\Facades\Hash;
12 use Illuminate\Validation\Rules;
14 class RegisteredUserController extends Controller
17 * Display the registration view.
19 * @return \Illuminate\View\View
21 public function create()
23 return view('auth.register');
27 * Handle an incoming registration request.
29 * @param \Illuminate\Http\Request $request
30 * @return \Illuminate\Http\RedirectResponse
32 * @throws \Illuminate\Validation\ValidationException
34 public function store(Request $request)
37 'name' => ['required', 'string', 'max:255'],
38 'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
39 'password' => ['required', 'confirmed', Rules\Password::defaults()],
42 $user = User::create([
43 'name' => $request->name,
44 'email' => $request->email,
45 'password' => Hash::make($request->password),
48 event(new Registered($user));
52 return redirect(RouteServiceProvider::HOME);