Can we use collection or array in table query?
I am creating a custom table in Filament, and I want to use a collection of data in the table. However, it seems that the table query in Filament does not support collections. What should I do to work with collections in my custom table?
Error
Filament\Tables\Table::query(): Argument #1 ($query) must be of type Illuminate\Database\Eloquent\Builder|Closure|null, Illuminate\Support\Collection given, called in /var/www/html/app/Filament/Pages/Reports/AccountStatement.php on line 45
Code
Collection Data
9 Replies
You can if you use sushi. There’s an article about it. Don’t have the link at the moment. Just do a search I’m sure you find it.
GitHub
GitHub - calebporzio/sushi: Eloquent's missing "array" driver.
Eloquent's missing "array" driver. Contribute to calebporzio/sushi development by creating an account on GitHub.
Yea that. But there’s an actual article about how to implement it with Filament tables.
I believe you are referring to this particular package. Let me verify if it suits my needs or not.
Filament
How to consume an external API with Filament Tables by Leandro Ferr...
A collection of beautiful full-stack components for Laravel. The perfect starting point for your next app. Using Livewire, Alpine.js and Tailwind CSS.
That’s the one.
But ultimately tables has to be an eloquent query. I know there’s some work going on around making it possible to use arrays etc, but there’s a lot of caveats and edge cases to being able to do it reliably.
Just wanted to drop a quick note to say thanks for recommending the sushi package. It did the trick and solved my problem perfectly. Your suggestion was spot on, and I really appreciate it!
No worries. Glad you got it working.
I apologize for bothering you, but I'd like to know how to pass dynamic values to a controller. I've successfully created a controller using Sushi, and now I'm looking to pass a dynamic value to the getRows method of Sushi from the Filament Resource class.
Controller
Somehow I managed to solve the setting parameter dynamically but I again hint at another problem of filtering the record based on account
Controller
Filament Resource
How can we update the static value of the model based on the filter?
⬆️
Can someone tell me how we can interact with table query?