[feature] elegant syntax update #229
Merged
+69
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is an attempt at making this package more elegant / easy to use.
The default locale when using the model accessor is the app locale,
In some cases you might need to get / set translations with a custom locale and if you do so the accessor is not usable without overriding the app locale.
In most cases you could just override the app locale for a short period of time but this feels dirty.
Instead of using the app locale this PR adds a
$locale
property on the trait that is used instead of the app locale when set.That makes it possible to use the accessor with any locale.
Example:
Imagine you want to save some data with the orm through a method:
Model:
Old way of doing it:
Or
New way:
This is just a basic example that shows what issue this PR tries to overcome