77use Illuminate \Support \Facades \DB ;
88use Illuminate \Support \Facades \Hash ;
99use Illuminate \Support \Facades \Validator ;
10+ use Illuminate \Validation \ValidationException ;
1011use Laravel \Fortify \Contracts \CreatesNewUsers ;
1112use Laravel \Jetstream \Jetstream ;
1213
@@ -18,12 +19,15 @@ class CreateNewUser implements CreatesNewUsers
1819 * Create a newly registered user.
1920 *
2021 * @param array<string, string> $input
22+ *
23+ * @throws ValidationException
2124 */
2225 public function create (array $ input ): User
2326 {
2427 Validator::make ($ input , [
2528 'name ' => ['required ' , 'string ' , 'max:255 ' ],
2629 'email ' => ['required ' , 'string ' , 'email ' , 'max:255 ' , 'unique:users ' ],
30+ 'username ' => ['required ' , 'string ' , 'max:255 ' , 'unique:users ' ],
2731 'password ' => $ this ->passwordRules (),
2832 'terms ' => Jetstream::hasTermsAndPrivacyPolicyFeature () ? ['accepted ' , 'required ' ] : '' ,
2933 ])->validate ();
@@ -32,6 +36,7 @@ public function create(array $input): User
3236 return tap (User::create ([
3337 'name ' => $ input ['name ' ],
3438 'email ' => $ input ['email ' ],
39+ 'username ' => $ input ['username ' ],
3540 'password ' => Hash::make ($ input ['password ' ]),
3641 ]), function (User $ user ) {
3742 $ this ->createTeam ($ user );
0 commit comments