F
Filament11mo ago
Ryuuuu

Sorting a table with a view as a column

So i have this filament table that doesn't have tradition columns, but instead has a view as a column like in the first pic. I managed to sort this by adding a sortBy to the end of my query builder in ->query(), modifying its parameters and running resetTable() to see the changes. The problem is that ->query() only takes a query builder, and i have a column thats calculated afterward that you can't find in the database, and i want to sort using this column. If i had access to the collection that results from the query builder, sortBy('column') would work, but since its not an actual column in the database, adding sortBy to the query builder gives an error. tl;dr: anyone know how i can access/sort a table's actual collection of records and not just the query builder from query()?
No description
1 Reply
Ryuuuu
RyuuuuOP11mo ago
bump I found this method included in the HasTable:
$this->sortTable($this->sortingColumn, $this->sortingDirection);
$this->sortTable($this->sortingColumn, $this->sortingDirection);
Which makes it alot cleaner than modifying the table query i guess, but it actually does the exact same thing So when i give it a column that doesnt exist in the database, i get the same eloquent error, because all this does is modify the query All i need is literally 1 step further, after the query is done, when its already an Eloquent Collection, where sortBy() function will work since the column is there now
Want results from more Discord servers?
Add your server