Skip to content

Commit

Permalink
fix: Fix localeKey attribute on shouldBeStrict() option (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
lwwcas authored Oct 1, 2024
1 parent fc2167d commit cd4b5f1
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/models/Country.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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.
*
Expand Down
9 changes: 9 additions & 0 deletions src/models/CountryGeographical.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -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();
Expand Down
9 changes: 9 additions & 0 deletions src/models/CountryRegion.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -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();
Expand Down

0 comments on commit cd4b5f1

Please sign in to comment.