F
Filament3mo ago
w5m

Sortable TextColumn based on Enum labels rather than query

I'm currently using a TaskStatus enum which implements the HasLabel contract. In this enum I've defined an orderedLabels() method to return an array of enum cases ordered by the corresponding labels. I've successfully utilised the enum in a form and in a table... TextColumn::make('task_status_id') ->label('Status') ->sortable() ->badge(), What I would ideally like to do is pass something into the sortable() method of the TextColumn which allows me to specify how to order the enum (as it currently orders by the task_status_id DB table field, an integer, which corresponds to an int-backed enum case). Other than backing the enum cases with integers which match alphabetical order, is there a way I could specify that sorting for this column should be done in alphabetical order of enum labels rather than via a query?
0 Replies
No replies yetBe the first to reply to this messageJoin