nova-belongsto-depend icon indicating copy to clipboard operation
nova-belongsto-depend copied to clipboard

Custom display name, Different column to display not showing

Open amitsingh9thjan opened this issue 2 years ago • 2 comments

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.

amitsingh9thjan avatar Jul 26 '22 18:07 amitsingh9thjan

any solution i'm having the same problem

ikramooe avatar Sep 07 '22 21:09 ikramooe

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();
                                    
           })

mageto avatar Jan 19 '23 23:01 mageto