Skip to content

Commit

Permalink
fix: use null coalescing operator
Browse files Browse the repository at this point in the history
This keeps PHP 7.3 support, since the null coalescing assigment
operator was introduced in PHP 7.4.
marijoo committed Nov 27, 2023
1 parent de259cf commit 36c44a3
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/Translatable.php
Original file line number Diff line number Diff line change
@@ -57,7 +57,7 @@ public static function make(array $fields): self

public function __construct(array $fields = [])
{
if (!count(static::$defaultLocales)) {
if (! count(static::$defaultLocales)) {
throw InvalidConfiguration::defaultLocalesNotSet();
}

@@ -66,7 +66,7 @@ public function __construct(array $fields = [])
$this->originalFields = $fields;

$this->displayLocalizedNameUsingCallback = self::$displayLocalizedNameByDefaultUsingCallback ?? function (Field $field, string $locale) {
return ucfirst($field->name) . " ({$locale})";
return ucfirst($field->name)." ({$locale})";
};

$this->createTranslatableFields();
@@ -188,9 +188,9 @@ protected function createTranslatedField(Field $originalField, string $locale):

$translatedField
->resolveUsing(function ($value, Model $model) use ($translatedField, $locale, $originalAttribute) {
$translatedField->attribute = 'translations_' . $originalAttribute . '_' . $locale;
$translatedField->panel ??= $this->panel;
$translatedField->assignedPanel ??= $this->assignedPanel;
$translatedField->attribute = 'translations_'.$originalAttribute.'_'.$locale;
$translatedField->panel = $translatedField->panel ?? $this->panel;
$translatedField->assignedPanel = $translatedField->assignedPanel ?? $this->assignedPanel;

return $model->translations[$originalAttribute][$locale] ?? '';
});
@@ -226,7 +226,7 @@ protected function createTranslatedField(Field $originalField, string $locale):

protected function onIndexPage(): bool
{
if (!request()->route()) {
if (! request()->route()) {
return false;
}

0 comments on commit 36c44a3

Please sign in to comment.