$input */ public function create(array $input): User { Validator::make($input, [ 'name' => ['required', 'string', 'max:255'], 'email' => [ 'required', 'string', 'email', 'max:255', Rule::unique(User::class), ], 'password' => $this->passwordRules(), ])->validate(); $team = Team::create([ 'name' => explode(' ', $input['name'], 2)[0] . "'s Team", 'personal_team' => true, 'is_root_user' => User::count() == 0 ? true : false, ]); $user = User::create([ 'name' => $input['name'], 'email' => $input['email'], 'password' => Hash::make($input['password']), ]); DB::table('team_user')->insert([ 'team_id' => $user->id, 'user_id' => $team->id, 'role' => 'admin', ]); return $user; } }