user()?->isMpbaPlatformAdmin(); } /** * Normalise ISO code inputs before validation. */ protected function prepareForValidation(): void { $this->merge([ 'alpha2' => strtoupper(trim((string) $this->input('alpha2'))), 'alpha3' => strtoupper(trim((string) $this->input('alpha3'))), 'numeric' => str_pad(trim((string) $this->input('numeric')), 3, '0', STR_PAD_LEFT), 'currency_code' => $this->filled('currency_code') ? strtoupper(trim((string) $this->input('currency_code'))) : null, 'ioc_code' => $this->filled('ioc_code') ? strtoupper(trim((string) $this->input('ioc_code'))) : null, 'fifa_code' => $this->filled('fifa_code') ? strtoupper(trim((string) $this->input('fifa_code'))) : null, ]); } /** * @return array */ public function rules(): array { $countryId = $this->route('country')?->id; return [ 'alpha2' => ['required', 'string', 'size:2', 'uppercase', Rule::unique('countries', 'alpha2')->ignore($countryId)], 'alpha3' => ['required', 'string', self::ISO3, 'uppercase', Rule::unique('countries', 'alpha3')->ignore($countryId)], 'numeric' => ['required', 'string', self::ISO3, Rule::unique('countries', 'numeric')->ignore($countryId)], 'name' => ['required', 'string', self::MAX_STRING], 'official_name' => ['nullable', 'string', self::MAX_STRING], 'common_name' => ['nullable', 'string', self::MAX_STRING], 'display_name' => ['nullable', 'string', self::MAX_STRING], 'native_name' => ['nullable', 'string', self::MAX_STRING], 'capital' => ['nullable', 'string', self::MAX_STRING], 'flag_emoji' => ['nullable', 'string', self::MAX_SHORT], 'calling_code' => ['nullable', 'string', self::MAX_SHORT], 'tld' => ['nullable', 'string', self::MAX_SHORT], 'currency_code' => ['nullable', 'string', self::ISO3, 'uppercase'], 'currency_name' => ['nullable', 'string', self::MAX_STRING], 'currency_symbol' => ['nullable', 'string', self::MAX_SHORT], 'languages' => ['nullable', 'json'], 'timezones' => ['nullable', 'json'], 'latitude' => ['nullable', 'numeric', 'between:-90,90'], 'longitude' => ['nullable', 'numeric', 'between:-180,180'], 'flag_svg_url' => ['nullable', 'url', self::MAX_STRING], 'flag_png_url' => ['nullable', 'url', self::MAX_STRING], 'ioc_code' => ['nullable', 'string', 'max:8'], 'fifa_code' => ['nullable', 'string', 'max:8'], 'postal_code_format' => ['nullable', 'string', self::MAX_STRING], 'address_format' => ['nullable', 'string', 'max:5000'], 'is_active' => ['required', 'boolean'], 'iso_status' => ['required', 'string', Rule::in(Iso3166::statuses())], 'independent' => ['nullable', 'boolean'], 'sovereignty_status' => ['nullable', 'string', 'max:64'], 'un_member' => ['nullable', 'boolean'], 'continent' => ['nullable', 'string', 'max:64'], 'region' => ['nullable', 'string', 'max:100'], 'subregion' => ['nullable', 'string', 'max:100'], 'intermediate_region' => ['nullable', 'string', self::MAX_STRING], 'sort_order' => ['nullable', 'integer', 'min:0', 'max:999999'], 'source' => ['nullable', 'string', self::MAX_STRING], 'source_version' => ['nullable', 'string', self::MAX_STRING], 'last_synced_at' => ['nullable', 'date'], 'metadata' => ['nullable', 'json'], ]; } }