$input */ public function create(array $input): User { Validator::make($input, [ ...$this->profileRules(), 'password' => $this->passwordRules(), ...$this->planRules(), ])->validate(); return User::create([ 'name' => $input['name'], 'email' => $input['email'], 'password' => $input['password'], ]); } /** * Get the validation rules for the chosen plan. * * The plan is only required when there is something configured to buy. This * keeps registration working on a deployment that has not set a Stripe * price yet, which would otherwise leave nobody able to create an account. * * @return array> */ protected function planRules(): array { $plans = array_keys(Organization::availablePlans()); if ($plans === []) { return []; } return [ 'plan' => ['required', Rule::in($plans)], ]; } }