Filament v3 modified table query pagination

    add this function in pages
    
    protected function paginateTableQuery(Builder $query): Paginator
    {

        $perPage = $this->getTableRecordsPerPage() === 'all'
            ? $query->count()
            : $this->getTableRecordsPerPage();

        $paginator = $query->simplePaginate($perPage);

        // Modify the collection and re-bind it to paginator
        $modified = $paginator->getCollection()->map(function ($record) {
            $record->new_attribute = 'new_value';
            return $record;
        });


        $paginator->setCollection($modified);

        return $paginator;
    }

Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *