You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
HI!
I'm using spatie/laravel-translatable, and it saves the translations as JSON and I can't find a way to get only the current locale translation so that I can use the data in protonemedia/inertiajs-tables-laravel-query-builder.
{"id":1,"name":{"en":"Service Name","pt":"Nome do Serviço"},"description":{"en":"Description","pt":"Descrição"},"icon":"icon.png","can_be_deleted":0,"created_at":"2023-01-04T16:06:50.000000Z","updated_at":"2023-01-04T16:06:50.000000Z"}
Let's say the current locale is "pt", how can I do it to get only the portuguese translation of the fields?
I've tried using QueryBuilder::for(MacroService::class)->allowedFields(['id', 'name->' . app()->getLocale() . ' as name', 'description->' . app()->getLocale() . ' as description', 'created_at', 'updated_at']) but the data sent to the browser is still the object with all the translations
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
HI!
I'm using spatie/laravel-translatable, and it saves the translations as JSON and I can't find a way to get only the current locale translation so that I can use the data in protonemedia/inertiajs-tables-laravel-query-builder.
{"id":1,"name":{"en":"Service Name","pt":"Nome do Serviço"},"description":{"en":"Description","pt":"Descrição"},"icon":"icon.png","can_be_deleted":0,"created_at":"2023-01-04T16:06:50.000000Z","updated_at":"2023-01-04T16:06:50.000000Z"}
Let's say the current locale is "pt", how can I do it to get only the portuguese translation of the fields?
I've tried using
QueryBuilder::for(MacroService::class)->allowedFields(['id', 'name->' . app()->getLocale() . ' as name', 'description->' . app()->getLocale() . ' as description', 'created_at', 'updated_at'])
but the data sent to the browser is still the object with all the translationsBeta Was this translation helpful? Give feedback.
All reactions