diff --git a/src/Helpers/CountryHelper.php b/src/Helpers/CountryHelper.php new file mode 100644 index 0000000..86d3e0f --- /dev/null +++ b/src/Helpers/CountryHelper.php @@ -0,0 +1,26 @@ +getByIsoCode($countryCode); + + self::$countriesByCode[$countryCode] = $country; + + return $country; + } +} diff --git a/src/Models/Address.php b/src/Models/Address.php index c32feeb..950e6fb 100644 --- a/src/Models/Address.php +++ b/src/Models/Address.php @@ -7,6 +7,7 @@ use DivineOmega\LaravelAddresses\DistanceStrategies\Direct; use DivineOmega\LaravelAddresses\Exceptions\InvalidCountryException; use DivineOmega\LaravelAddresses\Exceptions\InvalidUKPostcodeException; +use DivineOmega\LaravelAddresses\Helpers\CountryHelper; use DivineOmega\LaravelAddresses\Helpers\GoogleMaps; use DivineOmega\LaravelAddresses\Interfaces\DistanceStrategyInterface; use DivineOmega\LaravelAddresses\Objects\Location; @@ -50,7 +51,7 @@ public function getCountryAttribute(): ?Country return null; } - return (new Countries())->getByIsoCode($this->country_code); + return CountryHelper::getByIsoCode($this->country_code); } public function getCountryNameAttribute(): ?string