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
No description
No description
Solution:
You could use a virtual column
$table->string('full_name')->virtualAs('concat(first_name, \' \', last_name)');
$table->string('full_name')->virtualAs('concat(first_name, \' \', last_name)');
...
Jump to solution
2 Replies
Solution
LeandroFerreira
LeandroFerreira10mo ago
You could use a virtual column
$table->string('full_name')->virtualAs('concat(first_name, \' \', last_name)');
$table->string('full_name')->virtualAs('concat(first_name, \' \', last_name)');
Tables\Columns\TextColumn::make('agents.full_name')
->badge()
->searchable()
Tables\Columns\TextColumn::make('agents.full_name')
->badge()
->searchable()
mohdaftab
mohdaftabOP10mo ago
nice, thank you so much. Sorry, I thought I have to add it inside public static function table(Table $table): Table Please let me know where do I add it? Thank you so much. I see it has to be added in the schema. Thank you so much.
Want results from more Discord servers?
Add your server