outl1ne / nova-settings

A Laravel Nova tool for editing custom settings using native Nova fields.
MIT License
274 stars 96 forks source link

How I get translatable value via helper function? #20

Closed sharenjoy closed 4 years ago

sharenjoy commented 4 years ago

I think that this package support spatie/laravel-translatable. How I get translatable value via helper function?

liorocks commented 4 years ago

Let's assume you are using this package https://github.com/optimistdigital/nova-translatable to translate settings with spatie/laravel-translatable.

Text::make('Some Setting', 'setting_key')->translatable(),
json_decode(nova_get_setting('setting_key'), true)[app()->getLocale()]
Tarpsvo commented 4 years ago

You can make your own helper for these cases.

function nova_get_translatable_setting($key, $lang = 'en') {
  return nova_get_setting($key)[$lang] ?? null;
}
mialyGit commented 1 year ago

@Tarpsvo where do I make this helper please ?, I'am also using https://github.com/optimistdigital/nova-translatable