F
Filament12mo ago
Hugo

Broken Paginator after composer update ?

Hi, I've just done a composer update on my project, and since then I've had this error that persists and totally blocks me. I don't understand how to solve the problem. Error :
PHP Fatal error: Declaration of Filament\Tables\Concerns\InteractsWithTable::paginateTableQuery(Illuminate\Database\Eloquent\Builder $query): Illuminate\Contracts\Pagination\Paginator|Illuminate\Contracts\Pagination\CursorPaginator must be compatible with Filament\Widgets\TableWidget::paginateTableQuery(Illuminate\Database\Eloquent\Builder $query): Illuminate\Contracts\Pagination\Paginator in /home/hugo/projects/blouse-roses-v2/vendor/filament/tables/src/Concerns/CanPaginateRecords.php on line 28

Symfony\Component\ErrorHandler\Error\FatalError

Declaration of Filament\Tables\Concerns\InteractsWithTable::paginateTableQuery(Illuminate\Database\Eloquent\Builder $query): Illuminate\Contracts\Pagination\Paginator|Illuminate\Contracts\Pagination\CursorPaginator must be compatible with Filament\Widgets\TableWidget::paginateTableQuery(Illuminate\Database\Eloquent\Builder $query): Illuminate\Contracts\Pagination\Paginator

at vendor/filament/tables/src/Concerns/CanPaginateRecords.php:28
24▕
25▕ $this->resetPage();
26▕ }
27▕
28▕ protected function paginateTableQuery(Builder $query): Paginator | CursorPaginator
29▕ {
30▕ $perPage = $this->getTableRecordsPerPage();
31▕
32▕ /** @var LengthAwarePaginator $records */


Whoops\Exception\ErrorException
PHP Fatal error: Declaration of Filament\Tables\Concerns\InteractsWithTable::paginateTableQuery(Illuminate\Database\Eloquent\Builder $query): Illuminate\Contracts\Pagination\Paginator|Illuminate\Contracts\Pagination\CursorPaginator must be compatible with Filament\Widgets\TableWidget::paginateTableQuery(Illuminate\Database\Eloquent\Builder $query): Illuminate\Contracts\Pagination\Paginator in /home/hugo/projects/blouse-roses-v2/vendor/filament/tables/src/Concerns/CanPaginateRecords.php on line 28

Symfony\Component\ErrorHandler\Error\FatalError

Declaration of Filament\Tables\Concerns\InteractsWithTable::paginateTableQuery(Illuminate\Database\Eloquent\Builder $query): Illuminate\Contracts\Pagination\Paginator|Illuminate\Contracts\Pagination\CursorPaginator must be compatible with Filament\Widgets\TableWidget::paginateTableQuery(Illuminate\Database\Eloquent\Builder $query): Illuminate\Contracts\Pagination\Paginator

at vendor/filament/tables/src/Concerns/CanPaginateRecords.php:28
24▕
25▕ $this->resetPage();
26▕ }
27▕
28▕ protected function paginateTableQuery(Builder $query): Paginator | CursorPaginator
29▕ {
30▕ $perPage = $this->getTableRecordsPerPage();
31▕
32▕ /** @var LengthAwarePaginator $records */


Whoops\Exception\ErrorException
If anyone has any ideas, please let me know. Thank you
5 Replies
Hugo
HugoOP12mo ago
My widget :
<?php

namespace App\Filament\Resources\ActivityLocationResource\Pages;

use App\Filament\Resources\ActivityLocationResource;
use App\Models\ActivityLocation;
use Closure;
use Filament\Tables\Actions\Action;
use Filament\Tables\Actions\CreateAction;
use Filament\Tables\Columns\TextColumn;
use Filament\Widgets\TableWidget as BaseWidget;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Relations\Relation;

class ListActivityLocations extends BaseWidget
{
protected int|string|array $columnSpan = 'full';

protected static ?string $heading = 'Lieux';

protected function getTableQuery(): Builder|Relation|null
{
return ActivityLocation::query();
}

protected function getTableColumns(): array
{
return [
TextColumn::make('name')
->label('Lieu')
->searchable()
->sortable(),

TextColumn::make('committee.name')
->label('Comité')
->searchable()
->sortable(),
];
}

protected function getTableHeaderActions(): array
{
return [
CreateAction::make('create_activity_location')
->url(ActivityLocationResource::getUrl('create'))
->label('Nouveau Lieu'),
];
}

protected function getTableActions(): array
{
return [
Action::make('edit_activity_location')
->label('Modifier')
->icon('heroicon-m-pencil-square')
->url(fn(ActivityLocation $ActivityLocation): string => ActivityLocationResource::getUrl('edit', ['record' => $ActivityLocation])),
];
}

protected function getTableRecordUrlUsing(): ?Closure
{
return fn(ActivityLocation $ActivityLocation): string => ActivityLocationResource::getUrl('edit', ['record' => $ActivityLocation]);
}
}
<?php

namespace App\Filament\Resources\ActivityLocationResource\Pages;

use App\Filament\Resources\ActivityLocationResource;
use App\Models\ActivityLocation;
use Closure;
use Filament\Tables\Actions\Action;
use Filament\Tables\Actions\CreateAction;
use Filament\Tables\Columns\TextColumn;
use Filament\Widgets\TableWidget as BaseWidget;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Relations\Relation;

class ListActivityLocations extends BaseWidget
{
protected int|string|array $columnSpan = 'full';

protected static ?string $heading = 'Lieux';

protected function getTableQuery(): Builder|Relation|null
{
return ActivityLocation::query();
}

protected function getTableColumns(): array
{
return [
TextColumn::make('name')
->label('Lieu')
->searchable()
->sortable(),

TextColumn::make('committee.name')
->label('Comité')
->searchable()
->sortable(),
];
}

protected function getTableHeaderActions(): array
{
return [
CreateAction::make('create_activity_location')
->url(ActivityLocationResource::getUrl('create'))
->label('Nouveau Lieu'),
];
}

protected function getTableActions(): array
{
return [
Action::make('edit_activity_location')
->label('Modifier')
->icon('heroicon-m-pencil-square')
->url(fn(ActivityLocation $ActivityLocation): string => ActivityLocationResource::getUrl('edit', ['record' => $ActivityLocation])),
];
}

protected function getTableRecordUrlUsing(): ?Closure
{
return fn(ActivityLocation $ActivityLocation): string => ActivityLocationResource::getUrl('edit', ['record' => $ActivityLocation]);
}
}
DrByte
DrByte12mo ago
Those errors are saying that some filament core files aren't in sync with each other. So, it seems that some of the Filament core code didn't update completely during your composer update. That could be a result of your composer.json having hard-coded version numbers for certain filament packages, or you told Composer to only update a few packages but not everything. The quickest way to solve that is to completely delete all your composer packages and have composer reinstall them. That'll give you a clean fresh start. It shouldn't have any negative impact on deployments if your deployment process auto-installs composer packages during deployment. To delete your composer.lock and /vendor directory on mac/linux: rm -rf composer.lock vendor from your project root (where your .env file and composer.json are located). You can do it from a File Manager too. THEN run composer install to reload everything according to your composer.json contents.
Hugo
HugoOP12mo ago
@DrByte I've already done this at least 10 times and I always get this error at the end of the composer install. Here my composer.jsonfile :
Hugo
HugoOP12mo ago
Hugo
HugoOP12mo ago
I found the problem, in one of my TableWidget, I had a use InteractsWithTable, that's what was causing the problem.
Want results from more Discord servers?
Add your server