Concat 2 fields in 1 columns and be searchable

Hello. I am showing 2 phone nos in 1 columns using:
TextColumn::make('phone_nos')
->getStateUsing(function ($record) {
return $record->phone_no . ' / ' . $record->phone_no02;
})
->label(__('phone_nos'))
->searchable()
->toggleable()
->sortable(),
TextColumn::make('phone_nos')
->getStateUsing(function ($record) {
return $record->phone_no . ' / ' . $record->phone_no02;
})
->label(__('phone_nos'))
->searchable()
->toggleable()
->sortable(),
The problem is only for the search. It throws an error because field "phone_nos" does not exist in the database, obviously. Any suggestions? I need to do this with other kind of info, such as different emails. Tks.
3 Replies

Did you find this page helpful?