Table Filter multiple columns
How can I append 2 values/fields in Select filter? Currently I can only append one field to my filter.
5 Replies
I wan to appear first_name and last_name fields from db, but I can only appear first_name. May I know how can I do this?
In your Employee model create a custom attribute to bind a full_name like this.
And call "full_name" in your relation
->relationship('employee', 'full_name')
I don't remember, the case in the method name, but switch between getFullnameAttribute()
and getFullNameAttribute
, to create fullname
or full_name
custom attribute.The recommended way in the docs:
If you'd like to customize the label of each option, maybe to be more descriptive, or to concatenate a first and last name, you should use a virtual column in your database migration:
$table->string('full_name')->virtualAs('concat(first_name, \' \', last_name)');
Select::make('authorId')
->relationship('author', 'full_name')
Thanks @kennethsese and @jibaymcs for your suggestion. I think, Archilex suggestion is better, working and I found it in docs .