$input */ public function create(array $input): User { $settings = InstanceSettings::get(); if (!$settings->is_registration_enabled) { Log::info('Registration is disabled'); abort(403); } Validator::make($input, [ 'name' => ['required', 'string', 'max:255'], 'email' => [ 'required', 'string', 'email', 'max:255', Rule::unique(User::class), ], 'password' => $this->passwordRules(), ])->validate(); if (User::count() == 0) { // If this is the first user, make them the root user // Team is already created in the database/seeders/ProductionSeeder.php $user = User::create([ 'id' => 0, 'name' => $input['name'], 'email' => $input['email'], 'password' => Hash::make($input['password']), ]); $team = $user->teams()->first(); // Disable registration after first user is created $settings = InstanceSettings::get(); $settings->is_registration_enabled = false; $settings->save(); } else { $user = User::create([ 'name' => $input['name'], 'email' => $input['email'], 'password' => Hash::make($input['password']), ]); $team = $user->teams()->first(); } // Set session variable session(['currentTeam' => $user->currentTeam = $team]); return $user; } }