laravel-subscriptions icon indicating copy to clipboard operation
laravel-subscriptions copied to clipboard

Why overriding Spatie-translatable default getAttributeVlaue with static one??

Open BechirAhmed opened this issue 7 months ago • 0 comments

I'm wondering why you override the default getAttributeValue from Spatie-Translatable with this static config locale???

Spatie method:

public function getAttributeValue($key): mixed
    {
        if (! $this->isTranslatableAttribute($key)) {
            return parent::getAttributeValue($key);
        }

        return $this->getTranslation($key, $this->getLocale(), $this->useFallbackLocale());
    }

Your method:

public function getAttributeValue(mixed $key): mixed
    {
        if (! $this->isTranslatableAttribute($key)) {
            return parent::getAttributeValue($key);
        }

        return $this->getTranslation($key, config('app.locale')) ?: Arr::first($this->getTranslations($key));
    }

Why? Why config('app.locale')??

BechirAhmed avatar Mar 07 '25 20:03 BechirAhmed