| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294 | 
							- <?php
 - 
 - namespace App\Helpers;
 - 
 - use ArrayAccess;
 - use Illuminate\Support\Collection;
 - 
 - class Country implements ArrayAccess
 - {
 -     /**
 -      * The country data array.
 -      */
 -     protected array $data;
 - 
 -     /**
 -      * Create a new country instance.
 -      */
 -     public function __construct($data)
 -     {
 -         $this->setData($data);
 -     }
 - 
 -     /**
 -      * Set the country data array.
 -      */
 -     public function setData($data): static
 -     {
 -         if (is_array($data)) {
 -             $this->data = $data;
 -         } elseif ($data instanceof self) {
 -             $this->data = $data->getData();
 -         } else {
 -             $this->data = [];
 -         }
 - 
 -         return $this;
 -     }
 - 
 -     /**
 -      * Get the country data array.
 -      */
 -     public function getData(): ?array
 -     {
 -         return $this->data;
 -     }
 - 
 -     /**
 -      * Set a single country data array value.
 -      */
 -     public function set($key, $value): static
 -     {
 -         $this->data[$key] = $value;
 - 
 -         return $this;
 -     }
 - 
 -     /**
 -      * Get a single country data array value.
 -      */
 -     public function get($key): mixed
 -     {
 -         return $this->data[$key] ?? null;
 -     }
 - 
 -     /**
 -      * Check if an offset exists in the data array.
 -      */
 -     public function offsetExists($offset): bool
 -     {
 -         return isset($this->data[$offset]);
 -     }
 - 
 -     /**
 -      * Get an offset from the data array.
 -      */
 -     public function offsetGet($offset): mixed
 -     {
 -         return $this->data[$offset] ?? null;
 -     }
 - 
 -     /**
 -      * Set an offset in the data array.
 -      */
 -     public function offsetSet($offset, $value): void
 -     {
 -         if ($offset === null) {
 -             $this->data[] = $value;
 -         } else {
 -             $this->data[$offset] = $value;
 -         }
 -     }
 - 
 -     /**
 -      * Unset an offset in the data array.
 -      */
 -     public function offsetUnset($offset): void
 -     {
 -         unset($this->data[$offset]);
 -     }
 - 
 -     /**
 -      * Get the country id.
 -      */
 -     public function getId(): ?int
 -     {
 -         return $this->get('id');
 -     }
 - 
 -     /**
 -      * Get the country name.
 -      */
 -     public function getName(): ?string
 -     {
 -         return $this->get('name');
 -     }
 - 
 -     /**
 -      * Get the country iso2.
 -      */
 -     public function getIso2(): ?string
 -     {
 -         return $this->get('iso2');
 -     }
 - 
 -     /**
 -      * Get the country iso3.
 -      */
 -     public function getIso3(): ?string
 -     {
 -         return $this->get('iso3');
 -     }
 - 
 -     /**
 -      * Get the country numeric code.
 -      */
 -     public function getNumericCode(): ?string
 -     {
 -         return $this->get('numeric_code');
 -     }
 - 
 -     /**
 -      * Get the country phone code.
 -      */
 -     public function getPhoneCode(): ?string
 -     {
 -         return $this->get('phone_code');
 -     }
 - 
 -     /**
 -      * Get the country capital.
 -      */
 -     public function getCapital(): ?string
 -     {
 -         return $this->get('capital');
 -     }
 - 
 -     /**
 -      * Get the country currency code.
 -      */
 -     public function getCurrency(): ?string
 -     {
 -         return $this->get('currency');
 -     }
 - 
 -     /**
 -      * Get the country currency name.
 -      */
 -     public function getCurrencyName(): ?string
 -     {
 -         return $this->get('currency_name');
 -     }
 - 
 -     /**
 -      * Get the country currency symbol.
 -      */
 -     public function getCurrencySymbol(): ?string
 -     {
 -         return $this->get('currency_symbol');
 -     }
 - 
 -     /**
 -      * Get the country tld.
 -      */
 -     public function getTld(): ?string
 -     {
 -         return $this->get('tld');
 -     }
 - 
 -     /**
 -      * Get the country native name.
 -      */
 -     public function getNative(): ?string
 -     {
 -         return $this->get('native');
 -     }
 - 
 -     /**
 -      * Get the country region.
 -      */
 -     public function getRegion(): ?string
 -     {
 -         return $this->get('region');
 -     }
 - 
 -     /**
 -      * Get the country region id.
 -      */
 -     public function getRegionId(): ?int
 -     {
 -         return $this->get('region_id');
 -     }
 - 
 -     /**
 -      * Get the country subregion.
 -      */
 -     public function getSubregion(): ?string
 -     {
 -         return $this->get('subregion');
 -     }
 - 
 -     /**
 -      * Get the country subregion id.
 -      */
 -     public function getSubregionId(): ?int
 -     {
 -         return $this->get('subregion_id');
 -     }
 - 
 -     /**
 -      * Get the country nationality.
 -      */
 -     public function getNationality(): ?string
 -     {
 -         return $this->get('nationality');
 -     }
 - 
 -     /**
 -      * Get the country timezones.
 -      */
 -     public function getTimezones(): Collection
 -     {
 -         return collect($this->get('timezones') ?? []);
 -     }
 - 
 -     /**
 -      * Get the country translations.
 -      */
 -     public function getTranslations(): Collection
 -     {
 -         return collect($this->get('translations') ?? []);
 -     }
 - 
 -     /**
 -      * Get the country latitude.
 -      */
 -     public function getLatitude(): ?string
 -     {
 -         return $this->get('latitude');
 -     }
 - 
 -     /**
 -      * Get the country longitude.
 -      */
 -     public function getLongitude(): ?string
 -     {
 -         return $this->get('longitude');
 -     }
 - 
 -     /**
 -      * Get the country flag emoji.
 -      */
 -     public function getEmoji(): ?string
 -     {
 -         return $this->get('emoji');
 -     }
 - 
 -     /**
 -      * Get the country flag unicode.
 -      */
 -     public function getEmojiU(): ?string
 -     {
 -         return $this->get('emojiU');
 -     }
 - 
 -     /**
 -      * Get the country states.
 -      */
 -     public function getStates(): ?array
 -     {
 -         $countryCode = $this->getIso2();
 - 
 -         return LocationDataLoader::getAllStates($countryCode, false)->all();
 -     }
 - }
 
 
  |