Error when executing a table on a custom page

Hello everybody. I created a custom page and included a table. But when I run this page it gives the following message: "Table [App\Filament\Pages\Relatorios\RelatorioListaImoveis] must have a [query()].". What is missing to display the table correctly on the page? Thanks
class RelatorioListaImoveis extends Page implements Tables\Contracts\HasTable
{
use LivewireAlert;

use InteractsWithTable;

protected static ?string $model = Imovel::class;

protected static ?string $navigationIcon = 'fas-file-lines';

protected static string $view = 'filament.pages.relatorio-lista-imoveis';

public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('id'),
Tables\Columns\TextColumn::make('fantasia_contato')
->label('Nome Fantasia')
->sortable()
->searchable(),
Tables\Columns\TextColumn::make('ativo')
->label('Ativo')
->state(function (Imovel $record): string {
return $record->ativo == SimNaoEnum::SIM->value ? 'Sim' : 'Não';
})
->sortable(),
])
->paginated(false)
->filters([])
->actions([])
->bulkActions([]);
}

public function getTableQuery(): Builder
{
return Imovel::query();
}
}
class RelatorioListaImoveis extends Page implements Tables\Contracts\HasTable
{
use LivewireAlert;

use InteractsWithTable;

protected static ?string $model = Imovel::class;

protected static ?string $navigationIcon = 'fas-file-lines';

protected static string $view = 'filament.pages.relatorio-lista-imoveis';

public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('id'),
Tables\Columns\TextColumn::make('fantasia_contato')
->label('Nome Fantasia')
->sortable()
->searchable(),
Tables\Columns\TextColumn::make('ativo')
->label('Ativo')
->state(function (Imovel $record): string {
return $record->ativo == SimNaoEnum::SIM->value ? 'Sim' : 'Não';
})
->sortable(),
])
->paginated(false)
->filters([])
->actions([])
->bulkActions([]);
}

public function getTableQuery(): Builder
{
return Imovel::query();
}
}
2 Replies
diar
diar11mo ago
Hey @joao nivaldo did you find the solution I got the same error?
Want results from more Discord servers?
Add your server