lunar
lunar copied to clipboard
Enhancement/translations
Commit 77673f0f4712d8fa70658fbebe0158feb3fb5773 adds two scopes translation
and attributeTranslation
to constraint queries on translated model attributes and lunar attributes/fields.
Commit 438f915b73e31c3b5bf86d7b421038c26a1a5943 adds a AsTranslated
cast, applies it to all relevant models and refactors affected code.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
Name | Status | Preview | Comments | Updated (UTC) |
---|---|---|---|---|
lunar-docs | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Nov 13, 2023 3:00pm |
@netzknecht Can you explain what this is attempting to fix and is this something that is related to a discussion?
Hi @alecritson,
this is not a fix, it's an enhancement or extension.
Currently, lunar uses translations as json data in regular laravel database attributes/fields and in lunar attributes, too.
The new scopes in commit 77673f0 allows to query a model for a specific translation in both cases. That can be useful if you connect an external service and you must check the existence of a model by the translation.
The benefit of the second commit 438f915 is, that translated laravel database attributes are more strictly casted "AsTranslated" and all relevant accessor and mutator logic are at one place in the "AsTranslated" castable class. In addition, the accessor and mutator of the "AsTranslated" class converts everything that is no an array or collection into a collection with the current locale as locale key.
This isn't something we want to incorporate.