Compare commits

...
Sign in to create a new pull request.

1 commit

Author SHA1 Message Date
Jérémy Munsch
4ec00f8835
Proposal for nullalbe translatable field 2023-05-31 16:41:45 +02:00

View file

@ -67,6 +67,42 @@ trait HasTranslations
return parent::mutateAttributeForArray($key, $value);
}
/**
* Filter transalations to fetch
*
* ! Fix of spatie translatable.
*
* @param mixed $value
* @param string|null $locale
* @param array|null $allowedLocales
* @return boolean
*/
protected function filterTranslations(
mixed $value = null,
string $locale = null,
array $allowedLocales = null
): bool {
if ($value === null) {
// ! Overload this to allow nullable.
return true;
}
if ($value === '') {
return false;
}
if ($allowedLocales === null) {
return true;
}
if (!in_array($locale, $allowedLocales)) {
return false;
}
return true;
}
/**
* Retrieve the model for a bound value.
*