© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
9 replies
urbycoz

How can I sort by a custom Column

Here's the table data, which uses Account, Customer and Employee models:
Account::query()
->with([customer, employee])

Here are the relationships in the Account model

public function customer(): BelongsTo
{
return $this->belongsTo(Customer::class, 'contactid');
}

public function employee(): BelongsTo
{
return $this->belongsTo(Employee::class, 'contactid');
}

...and the aggregated attribute:

public function getCombinedNameAttribute()
{
if ($this->contactType == 'Customer'){
return $this->customer->name
}
elseIf ($this->contactType == 'Employee'){
return $this->employee->fullname
}

}

The text column works fine, but I just can't make it sortable. The code below doesn't seem to work:

TextColumn::make('combined_name')
->sortable()
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

how to sort a custom column
FilamentFFilament / ❓┊help
3y ago
How can I sort a table on a custom page?
FilamentFFilament / ❓┊help
3y ago
How can I sort by value string on table?
FilamentFFilament / ❓┊help
16mo ago
Can I sort table on non-column data
FilamentFFilament / ❓┊help
15mo ago