Try the suggested answer on the discussions page of FilamentPHP: https://github.com/filamentphp/filament/discussions/2283
Jul 4, 2022
1
Level 1
Use External API with Datatable
I am new to laravel. IDK why but everyone on the internet is teaching how to build data tables from the Database model. But I think another widespread use case is External APIs, in my case I call an API from livewire's controller. API return an Array.
How can I put this data into a beautiful user-friendly data table? I want to use Filament Table (Because I think it has the most beautiful user interface out-of-box.)
According to their docs, they expect an Eloquent Builder.
protected function getTableQuery(): Builder
{
return $this->keywordData;
}
As expected this throws an error.
TypeError
App\Http\Livewire\COMONENTNAME::getTableQuery(): Return value must be of type Illuminate\Database\Eloquent\Builder, array returned (View: C:\PROJECTPATH\resources\views\livewire\COMONENTNAME.blade.php)
Please or to participate in this conversation.