Modify label in select options

Forms\Components\Select::make('song_id')
    ->relationship(name: 'song', titleAttribute: 'name')


id like to change the title attribute, i currently have it like this (song name):
Levels


but id like to show the artist too:
Avicii - Levels


but idk how to do it hmmm
Solution
final code:
Forms\Components\Select::make('song_id')
    ->searchable()
    ->relationship(name: 'song', titleAttribute: 'name')
    ->required()
    ->getOptionLabelFromRecordUsing(function (Song $record) {
        $artistName = $record->artists()->first()?->name ?? '';

        return "{$artistName} - {$record->name}";
    })
,


like this works fine
Was this page helpful?