$input * * @throws AuthorizationException * @throws ValidationException */ public function create(User $user, array $input): Organization { Gate::forUser($user)->authorize('create', Jetstream::newTeamModel()); Validator::make($input, [ 'name' => ['required', 'string', 'max:255'], ])->validateWithBag('createTeam'); $ipLookupResponse = app(IpLookupServiceContract::class)->lookup(request()->ip()); $currency = null; if ($ipLookupResponse !== null) { $currency = $ipLookupResponse->currency; } $organization = app(OrganizationService::class)->createOrganization( $input['name'], $user, false, $currency ); $user->switchTeam($organization); // Note: The refresh is necessary for currently unknown reasons. Do not remove it. $organization = $organization->refresh(); AfterCreateOrganization::dispatch($organization); return $organization; } }