Cursor Pagination Not Working with Filament Table Tabs

According to the document, when I am applying the cursor pagination method, it's throwing an error "Call to a member function encode() on null" .Does anyone know how I can fix it? Please check below flare link https://flareapp.io/share/bP9n4KD7
<?php
class ListProductVariants extends ListRecords
{
public function getTabs(): array
{
return [
'new' => Tab::make()
->modifyQueryUsing(fn (Builder $query) => $query
->where('is_created', 0)
->where('is_archived', false)),
'enabled' => Tab::make()
->modifyQueryUsing(fn (Builder $query) => $query
->where('is_created', 1)
->where('is_approved', 1)
->where('is_archived', false)),
'disabled' => Tab::make()
->modifyQueryUsing(fn (Builder $query) => $query
->where('is_created', 1)
->where('is_approved', 0)
->where('is_archived', false)),
'archived' => Tab::make()
->modifyQueryUsing(fn (Builder $query) => $query
->where('is_archived', true)),
];
}

protected function paginateTableQuery(Builder $query): CursorPaginator
{
return $query->cursorPaginate(($this->getTableRecordsPerPage() === 'all') ? $query->count() : $this->getTableRecordsPerPage());
}
}
<?php
class ListProductVariants extends ListRecords
{
public function getTabs(): array
{
return [
'new' => Tab::make()
->modifyQueryUsing(fn (Builder $query) => $query
->where('is_created', 0)
->where('is_archived', false)),
'enabled' => Tab::make()
->modifyQueryUsing(fn (Builder $query) => $query
->where('is_created', 1)
->where('is_approved', 1)
->where('is_archived', false)),
'disabled' => Tab::make()
->modifyQueryUsing(fn (Builder $query) => $query
->where('is_created', 1)
->where('is_approved', 0)
->where('is_archived', false)),
'archived' => Tab::make()
->modifyQueryUsing(fn (Builder $query) => $query
->where('is_archived', true)),
];
}

protected function paginateTableQuery(Builder $query): CursorPaginator
{
return $query->cursorPaginate(($this->getTableRecordsPerPage() === 'all') ? $query->count() : $this->getTableRecordsPerPage());
}
}
Flare
Flare
No description
5 Replies
Sourabh
SourabhOP2w ago
I’m experiencing slow performance when listing 1 million rows in a Filament table with tabs. Could anyone suggest the best way to optimize it?
toeknee
toeknee2w ago
Are you listing them all at once?
Sourabh
SourabhOP2w ago
No, I am not displaying all items at once.
<?php
return $table->paginated([5, 10, 25, 50, 100, 200]);
<?php
return $table->paginated([5, 10, 25, 50, 100, 200]);
toeknee
toeknee2w ago
So there is no reason to be slow, apart from a badly optimised DB. Ensure for each of the tab queries you are indexed for the column. Best bet to install a debugger like debubar or teleport and inspect what is slow.
Sourabh
SourabhOP2w ago
Okay, I will check after applying indexing and update you accordingly.

Did you find this page helpful?