Concating Fields in Select Option

I need to add the Project Name and IDs to select options. I have used a mutator in the model shown below.

protected function NameAndID(): Attribute
{
return Attribute::make(
get: fn() => $this->ProjectID . ' - ' . $this->ProjectName,
);
}

The NameAndID column works great in the form but not the filters where

SelectFilter::make('PaymentProjectID')->relationship('project', 'NameAndID')->label('Project'),

Gives me

Column not found: 1054 Unknown column 'project.NameAndID' in 'field list'

Any advise gratefully received!
Solution
SelectFilter::make('PaymentProjectID')
  ->relationship('project', 'ProjectName')
  ->getOptionLabelFromRecordUsing(fn($record) => $record->NameAndID)->label('Project'),

Is the ticket
Was this page helpful?