Table not Listing All Records
I am trying to create a ListAllVersionsForPage resource so the users can see all Versions for a given page:
Currently my code looks like the following.
And I can see the following logged out
<?php
namespace App\Filament\Resources\PageVersions\Pages;
use BackedEnum;
use App\Filament\Resources\PageVersions\PageVersionResource;
use App\Models\PageVersion;
use Filament\Actions\CreateAction;
use Filament\Resources\Pages\ListRecords;
use Filament\Support\Icons\Heroicon;
use Filament\Actions\EditAction;
use Filament\Actions\ViewAction;
use Filament\Tables\Columns\BadgeColumn;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
class ListPageVersionsForPage extends ListRecords
{
protected static string $resource = PageVersionResource::class;
protected static ?string $title = 'Page Versions';
protected static ?string $navigationLabel = 'All Versions';
protected static string | BackedEnum | null $navigationIcon = 'heroicon-o-queue-list';
public function getTitle(): string
{
$pageVersionId = request()->route('record');
$pageVersion = PageVersion::find($pageVersionId);
$pageTitle = $pageVersion?->page?->title ?? 'Unknown Page';
$versionsCount = PageVersion::where('page_id', $pageVersion?->page_id)->count();
return "All Versions - {$pageTitle} ({$versionsCount} versions)";
}
public static function getNavigationLabel(): string
{
return 'All Versions';
}
protected function getTableQuery(): Builder
{
$current = PageVersion::findOrFail(request()->route('record'));
return PageVersion::query()
->where('page_id', $current->page_id)
->tap(fn ($q) => logger()->info('SQL: ' . $q->toRawSql() . ' - Bindings: ' . json_encode($q->getBindings())));
}
public function table(Table $table): Table
{
return $table
->columns([
TextColumn::make('version_number')->label('Version')->sortable()->badge()->color('primary'),
BadgeColumn::make('status')->color(fn (string $state) => match ($state) {
'published' => 'success',
'draft' => 'warning',
'archived' => 'danger',
default => 'gray',
}),
TextColumn::make('meta_title')->label('SEO Title')->searchable()->limit(50)->placeholder('No SEO Title'),
TextColumn::make('created_at')->dateTime()->sortable()->label('Created'),
TextColumn::make('published_at')->dateTime()->sortable()->placeholder('Not published'),
TextColumn::make('content')->formatStateUsing(function ($state) {
if (!is_array($state) || empty($state)) return 'No Content';
$blockCount = count($state);
$blockTypes = array_unique(array_map(fn ($b) => $b['type'] ?? 'unknown', $state));
return "Builder Content ({$blockCount} blocks: " . implode(', ', $blockTypes) . ")";
})->toggleable(isToggledHiddenByDefault: true),
])
->actions([ViewAction::make(), EditAction::make()])
->defaultSort('version_number', 'desc');
}
}
<?php
namespace App\Filament\Resources\PageVersions\Pages;
use BackedEnum;
use App\Filament\Resources\PageVersions\PageVersionResource;
use App\Models\PageVersion;
use Filament\Actions\CreateAction;
use Filament\Resources\Pages\ListRecords;
use Filament\Support\Icons\Heroicon;
use Filament\Actions\EditAction;
use Filament\Actions\ViewAction;
use Filament\Tables\Columns\BadgeColumn;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
class ListPageVersionsForPage extends ListRecords
{
protected static string $resource = PageVersionResource::class;
protected static ?string $title = 'Page Versions';
protected static ?string $navigationLabel = 'All Versions';
protected static string | BackedEnum | null $navigationIcon = 'heroicon-o-queue-list';
public function getTitle(): string
{
$pageVersionId = request()->route('record');
$pageVersion = PageVersion::find($pageVersionId);
$pageTitle = $pageVersion?->page?->title ?? 'Unknown Page';
$versionsCount = PageVersion::where('page_id', $pageVersion?->page_id)->count();
return "All Versions - {$pageTitle} ({$versionsCount} versions)";
}
public static function getNavigationLabel(): string
{
return 'All Versions';
}
protected function getTableQuery(): Builder
{
$current = PageVersion::findOrFail(request()->route('record'));
return PageVersion::query()
->where('page_id', $current->page_id)
->tap(fn ($q) => logger()->info('SQL: ' . $q->toRawSql() . ' - Bindings: ' . json_encode($q->getBindings())));
}
public function table(Table $table): Table
{
return $table
->columns([
TextColumn::make('version_number')->label('Version')->sortable()->badge()->color('primary'),
BadgeColumn::make('status')->color(fn (string $state) => match ($state) {
'published' => 'success',
'draft' => 'warning',
'archived' => 'danger',
default => 'gray',
}),
TextColumn::make('meta_title')->label('SEO Title')->searchable()->limit(50)->placeholder('No SEO Title'),
TextColumn::make('created_at')->dateTime()->sortable()->label('Created'),
TextColumn::make('published_at')->dateTime()->sortable()->placeholder('Not published'),
TextColumn::make('content')->formatStateUsing(function ($state) {
if (!is_array($state) || empty($state)) return 'No Content';
$blockCount = count($state);
$blockTypes = array_unique(array_map(fn ($b) => $b['type'] ?? 'unknown', $state));
return "Builder Content ({$blockCount} blocks: " . implode(', ', $blockTypes) . ")";
})->toggleable(isToggledHiddenByDefault: true),
])
->actions([ViewAction::make(), EditAction::make()])
->defaultSort('version_number', 'desc');
}
}
[2025-09-02 13:39:03] local.INFO: SQL: select * from "page_versions" where "page_id" = 1 - Bindings: [1]
When looking at my database I can see there are two records as displayes in the attached photo. However when loading the page I get the following displayed:

1 Reply
Solution
Figured it out
public function table(Table $table): Table
{
return $table
->modifyQueryUsing(function (Builder $query) {
$current = PageVersion::findOrFail(request()->route('record'));
return PageVersion::query()
->where('page_id', $current->page_id);
})
->columns([
TextColumn::make('version_number')->label('Version')->sortable()->badge()->color('primary'),
BadgeColumn::make('status')->color(fn (string $state) => match ($state) {
'published' => 'success',
'draft' => 'warning',
'archived' => 'danger',
default => 'gray',
}),
TextColumn::make('meta_title')->label('SEO Title')->searchable()->limit(50)->placeholder('No SEO Title'),
TextColumn::make('created_at')->dateTime()->sortable()->label('Created'),
TextColumn::make('published_at')->dateTime()->sortable()->placeholder('Not published'),
TextColumn::make('content')->formatStateUsing(function ($state) {
if (!is_array($state) || empty($state)) return 'No Content';
$blockCount = count($state);
$blockTypes = array_unique(array_map(fn ($b) => $b['type'] ?? 'unknown', $state));
return "Builder Content ({$blockCount} blocks: " . implode(', ', $blockTypes) . ")";
})->toggleable(isToggledHiddenByDefault: true),
])
->actions([ViewAction::make(), EditAction::make()])
->defaultSort('version_number', 'desc');
}
public function table(Table $table): Table
{
return $table
->modifyQueryUsing(function (Builder $query) {
$current = PageVersion::findOrFail(request()->route('record'));
return PageVersion::query()
->where('page_id', $current->page_id);
})
->columns([
TextColumn::make('version_number')->label('Version')->sortable()->badge()->color('primary'),
BadgeColumn::make('status')->color(fn (string $state) => match ($state) {
'published' => 'success',
'draft' => 'warning',
'archived' => 'danger',
default => 'gray',
}),
TextColumn::make('meta_title')->label('SEO Title')->searchable()->limit(50)->placeholder('No SEO Title'),
TextColumn::make('created_at')->dateTime()->sortable()->label('Created'),
TextColumn::make('published_at')->dateTime()->sortable()->placeholder('Not published'),
TextColumn::make('content')->formatStateUsing(function ($state) {
if (!is_array($state) || empty($state)) return 'No Content';
$blockCount = count($state);
$blockTypes = array_unique(array_map(fn ($b) => $b['type'] ?? 'unknown', $state));
return "Builder Content ({$blockCount} blocks: " . implode(', ', $blockTypes) . ")";
})->toggleable(isToggledHiddenByDefault: true),
])
->actions([ViewAction::make(), EditAction::make()])
->defaultSort('version_number', 'desc');
}