BelongsToMany TextColumn first_name last_name searchable

Hello,

How do I make the TextColumn searchable by first_name and last_name for a belongsToMany relationship please?
I have a property listing attached to users table with relationship name as "agents" and I need to make the agent name searchable in TextColumn please.
Please see the attached pictures for the code.
Thank you
image.png
image.png
Solution
You could use a virtual column

$table->string('full_name')->virtualAs('concat(first_name, \' \', last_name)');


Tables\Columns\TextColumn::make('agents.full_name')
    ->badge()
    ->searchable()
Was this page helpful?