I want to date to my api from filters
I have called an internal api to show some data in my custom page. That api needs start date and end date parameters. How can I pass the parameters in the api ? The dates are selected in the fliter from datepicker
15 Replies
make an eloquentmodel with Sushi
https://filamentphp.com/blog/how-to-consume-an-external-api-with-filament-tables
Filament
How to consume an external API with Filament Tables by Leandro C. F...
Filament is a collection of tools for rapidly building beautiful TALL stack apps, designed for humans.
After you can write a method to this model
https://pastebin.com/XS4EMRXi
then in getTableQuery(): Builder
you can init your model with parameters
https://pastebin.com/vCGw509Y
I use this approach
Pastebin
protected function getTableQuery(): Builder { $filter...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
but you can find it here also:
https://github.com/leandrocfe/filament-tables-json-data-source/issues/1
GitHub
API endpoint filter · Issue #1 · leandrocfe/filament-tables-json-d...
hi, How would you pass parameters (from the filament filters) to the API endpoint URL/body? thanks for your implementation btw :)
Thank you
But it looks like Sushi needs model but my internal api is not related to a single model but instead generates a report based on multiple models
please share the code..
Not sure but can you access
$this->tableFilters
?$this->tableFilters this gave null but I used HasFilters in the page and then did $this->getTableFilters(), it gave me the whole filter. Since I only need the value, I did $from = $filters[0]->getState()['from'] but error occured.
this is the error :
Typed property Filament\Tables\Filters\BaseFilter::$table must not be accessed before initialization
You can try something like this:
$this->apiData is coming null. The code did not go inside this updated() function.
Isn't the updated method called when you change the dates?
No. Even when I select dates the code is not going in the updated method and apiData is returning null
Can you share the whole code on github?