-
-
Notifications
You must be signed in to change notification settings - Fork 170
Open
Description
Currently, the withTranslation method does not allow selecting specific fields from the translations table while querying the translateable model. For example, I want to retrieve only certain translations (e.g., description) alongside selected fields from the translateable model, but this is not possible in a clean and efficient way.
I would like the ability to query translations more concisely and intuitively, such as:
$model = Model::select('id')->withTranslation(['description'])->get();
This approach would be cleaner and more aligned with Laravel's Eloquent principles, avoiding the need for more verbose solutions like:
$model = Model::with(['translations' => function ($query) {
$query->where('locale', app()->getLocale())
->select('model_id', 'description', 'locale');
}])->get();
The proposed syntax makes the query more readable and reduces boilerplate code.
Dezmonter
Metadata
Metadata
Assignees
Labels
No labels