F
Filament14mo ago
qcol

Custom hierarchical (tree) table - filament or custom row by row?

I am trying to build a hierarchical table that will include row grouping, collapsing and expanding groups (tree structure). One of the columns must contain textinput, at the end of the table a submit button to save changes. The package https://github.com/staudenmeir/laravel-adjacency-list is very helpful here. I am doing tests with database queries and with this package I can easily build a tree structure in plain HTML.
Trying to do this in the Filament table but right at the beginning I have a problem because I can't use the query->(Product::find($product_id)->descendants) because package generate ready to use collection, so there is an error (query must be Builder|Closure|null, Collection given) Question 1. How to get around the error to be able to use the filament table?
Question 2. It is possible that the best way, however, would be to build such a table outside the filament, with loop, row by row. How to do it to use filament components (table with grouping/collapse/expansion)?. Is there somewhere an example of building such a custom table (I can't find)?
GitHub
GitHub - staudenmeir/laravel-adjacency-list: Recursive Laravel Eloq...
Recursive Laravel Eloquent relationships with CTEs - GitHub - staudenmeir/laravel-adjacency-list: Recursive Laravel Eloquent relationships with CTEs
1 Reply
Fogzy
Fogzy13mo ago
I would do this using a query string, e.g. parentId. Starting with no parentId, I would limit the query to only parent_id = NULL (level=0). Then I would put links in each row to the same table, but with the query string parentId=$row->id. You would then change the base query to look only for records with parent_id = $parentId.
Want results from more Discord servers?
Add your server