how to sort a custom column
so i have a custom column that has only an integer value, and im wondering how to make it sortable π€
8 Replies
Is this an attribute on your model? I think you would need this column in the eloquent query for
->sortable()
to work. (Could be a computed column, like select ... as wins
)is not an attribute, is a value i calculate on the way
i dont want to store that the value in the db, but calculate it instead, is there alternatives?
if there is no alternatives, what would u do?
Where does the
wins
data come from? DB or somewhere else?comes from a method inside the model
its a calculation of how many wins has, depending on some factors
Sure but ultimately, where is this information stored? How do you calculate the wins?
this calculations are shown in that view, not stored
Ok, not sure I understand but... One direction to explore would be to create a Sushi model just for display:
https://filamentphp.com/blog/how-to-consume-an-external-api-with-filament-tables
This tutorial fetches data from an external API but you could assemble it internally, according to your own business logic.
All columns will be sortable.
that is interesting!
thank u