F
Filamentβ€’2mo ago
Frans

Add a table in a custom filament page using table builder

Good day! I am new to filament and I want to display a table in a custom filament page using the table builder. However I am getting an error: Argument #1 ($table) must be of type Filament\Tables\Table, Filament\Infolists\Infolist given, called vendor\filament\infolists\src\Concerns\InteractsWithInfolists.php Custom Page:
namespace App\Filament\Pages;

use Filament\Pages\Page;
use Filament\Tables\Table;
use App\Models\MalasakitSummary;
use Filament\Tables\Columns\TextColumn;

class MalasakitDashboard extends Page
{
protected static string $view = 'filament.pages.malasakit-dashboard';

protected static ?string $title = 'Malasakit Dashboard';
protected static ?string $navigationLabel = 'Dashboard';
protected static ?string $slug = 'malasakit-centers/dashboard';
protected ?string $heading = 'Malaskit Dashboard';
protected static ?string $navigationGroup = 'Malasakit';

public static function table(Table $table): Table
{
return $table
->query(MalasakitSummary::query())
->columns([
TextColumn::make('name')
->label('Name'),
]);
}
}
namespace App\Filament\Pages;

use Filament\Pages\Page;
use Filament\Tables\Table;
use App\Models\MalasakitSummary;
use Filament\Tables\Columns\TextColumn;

class MalasakitDashboard extends Page
{
protected static string $view = 'filament.pages.malasakit-dashboard';

protected static ?string $title = 'Malasakit Dashboard';
protected static ?string $navigationLabel = 'Dashboard';
protected static ?string $slug = 'malasakit-centers/dashboard';
protected ?string $heading = 'Malaskit Dashboard';
protected static ?string $navigationGroup = 'Malasakit';

public static function table(Table $table): Table
{
return $table
->query(MalasakitSummary::query())
->columns([
TextColumn::make('name')
->label('Name'),
]);
}
}
View:
<x-filament-panels::page>
{{ $this->table }}
</x-filament-panels::page>
<x-filament-panels::page>
{{ $this->table }}
</x-filament-panels::page>
Should I use other ways to do this such as livewire component, table widget, or hard coding a table then pass the data? Thank you.
Solution:
I think you need to implements HasTable like this ```php use Filament\Tables\Contracts\HasTable; use Filament\Tables\Concerns\InteractsWithTable; ...
Jump to solution
2 Replies
Solution
Vp
Vpβ€’2mo ago
I think you need to implements HasTable like this
use Filament\Tables\Contracts\HasTable;
use Filament\Tables\Concerns\InteractsWithTable;

class MalasakitDashboard extends Page implements HasTable
{
use InteractsWithTable;

// ...
}
use Filament\Tables\Contracts\HasTable;
use Filament\Tables\Concerns\InteractsWithTable;

class MalasakitDashboard extends Page implements HasTable
{
use InteractsWithTable;

// ...
}
Frans
Fransβ€’2mo ago
Nice! That worked. Thank you! πŸ‘Œ