From 27c9efae784591c9c5ba76c4523b60951368ca62 Mon Sep 17 00:00:00 2001 From: Felix <30987125+flxcn@users.noreply.github.com> Date: Fri, 29 Jul 2022 13:41:36 -0400 Subject: [PATCH] Update RegisterController.php --- app/Http/Controllers/Auth/RegisterController.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index 16e8db1..a2afbd5 100644 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -54,6 +54,7 @@ protected function validator(array $data) 'grad_year' => ['required', 'integer'], 'email' => ['required', 'string', 'email', 'max:255', 'unique:users'], 'password' => ['required', 'string', 'min:8', 'confirmed'], + 'role' => 'required' ]); } @@ -65,11 +66,15 @@ protected function validator(array $data) */ protected function create(array $data) { - return User::create([ + $user = User::create([ 'name' => $data['name'], 'grad_year' => $data['grad_year'], 'email' => $data['email'], 'password' => Hash::make($data['password']), ]); + + $user->assignRole($data['role']); + + return $user; } }