diff --git a/src/models/Country.php b/src/models/Country.php index d40c472..df1ed60 100644 --- a/src/models/Country.php +++ b/src/models/Country.php @@ -30,6 +30,9 @@ class Country extends Model /* Translatable ForeignKey */ public $translationForeignKey = 'lc_country_id'; + /* @property-read string $localeKey */ + public string $localeKey; + /** * The attributes that are mass assignable. * @@ -78,6 +81,12 @@ class Country extends Model 'visible' => 'boolean', ]; + public function __construct(array $attributes = []) + { + $this->localeKey = config('translatable.locale_key', 'locale'); + parent::__construct($attributes); + } + /** * The "booting" method of the model. * diff --git a/src/models/CountryGeographical.php b/src/models/CountryGeographical.php index 41fccb0..d344956 100644 --- a/src/models/CountryGeographical.php +++ b/src/models/CountryGeographical.php @@ -18,6 +18,9 @@ class CountryGeographical extends Model */ protected $table = 'lc_countries_geographical'; + /* @property-read string $localeKey */ + public string $localeKey; + /** * The attributes that are mass assignable. * @@ -42,6 +45,12 @@ class CountryGeographical extends Model 'geometry' => Json::class, ]; + public function __construct(array $attributes = []) + { + $this->localeKey = config('translatable.locale_key', 'locale'); + parent::__construct($attributes); + } + public static function boot() { parent::boot(); diff --git a/src/models/CountryRegion.php b/src/models/CountryRegion.php index 8726adb..e691511 100644 --- a/src/models/CountryRegion.php +++ b/src/models/CountryRegion.php @@ -29,6 +29,9 @@ class CountryRegion extends Model /* Translatable ForeignKey */ public $translationForeignKey = 'lc_region_id'; + /* @property-read string $localeKey */ + public string $localeKey; + /** * The attributes that are mass assignable. * @@ -38,6 +41,12 @@ class CountryRegion extends Model 'uuid', ]; + public function __construct(array $attributes = []) + { + $this->localeKey = config('translatable.locale_key', 'locale'); + parent::__construct($attributes); + } + public static function boot() { parent::boot();