nova-belongsto-depend
nova-belongsto-depend copied to clipboard
Custom display name, Different column to display not showing
NovaBelongsToDepend::make('Shows', 'shows', \App\Nova\Shows::class) ->placeholder('-- Select Show --') // Add this just if you want to customize the placeholder ->options(Shows::all()) ->display(function($shows){ return $shows->title . ' - ' . $shows->en_title; }),
I'm trying this but it's not showing display attribute content.
any solution i'm having the same problem
You can try to map the array like below and see if it works for you.
->optionsResolve(function ($shows) {
return $shows->get(['title', 'en_title'])
->pluck('title', 'en_title')
->map(function($title, $key) {
return ['title' => $key, 'en_title' => $key . ' - ' . $en_title];
})
->values()
->toArray();
})