abkrim
2 weeks ago
111
3
Nova

Translation of BelongsTo in Nova

Posted 2 weeks ago by abkrim

I use for translations fields in Nova

Text::make(__('Name User'), 'name')

But I don't understand the manual to make the title of the BelongsTo fields translatable

Title Attributes When a BelongsTo field is shown on a resource creation / update screen, a drop-down selection menu or search menu will display the "title" of the resource. For example, a User resource may use the name attribute as its title. Then, when the resource is shown in a BelongsTo selection menu, that attribute will be displayed:

Well... On my code

BelongsTo::make('User')->withMeta([
  'belongsToId' =>  $this->user_id ?? auth()->user()->id
])->hideFromDetail()

Code on Nova\User

public static $model = 'App\User';

public static $title = 'email';

public static $search = ['id', 'name', 'email'];

public static function availableForNavigation(Request $request)
{
    return $request->user()->isAdmin();
}

public static function label()
{
    return __('Users');
}

public static function singularLabel()
{
    return __('User');
}

When show User resource not problem. Labels translations are done.

But if go to resource Mailbox, field BelongsTo not show translations

Please sign in or create an account to participate in this conversation.