Skip to content

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

@BechirAhmed

Description

@BechirAhmed

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')??

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions