Can not add table to a component

I have a custom component where i want to display a table. Implemented the trait and interface:
class ConfirmMailing extends Component implements HasForms, HasTable
{
use InteractsWithTable;
use InteractsWithForms;
class ConfirmMailing extends Component implements HasForms, HasTable
{
use InteractsWithTable;
use InteractsWithForms;
Now the problem is adding the table method, this expects to return a Table , but the underlying trait expects Static as return type. This is according to the docs:
public function table(Table $table): Table
{
return $table
->query(Mailing::query())
->columns([
TextColumn::make('id'),
])
->filters([
// ...
])
->actions([
// ...
])
->bulkActions([
// ...
]);
}
public function table(Table $table): Table
{
return $table
->query(Mailing::query())
->columns([
TextColumn::make('id'),
])
->filters([
// ...
])
->actions([
// ...
])
->bulkActions([
// ...
]);
}
And when checking the trait HasTables, the method is like this:
interface HasTable
{
public function table(Table $table): static;
interface HasTable
{
public function table(Table $table): static;
So this will result in the following error:
Declaration of App\Livewire\Tables\ConfirmMailing::table(Filament\Tables\Table $table) must be compatible with Filament\Tables\Actions\Contracts\HasTable::table
Declaration of App\Livewire\Tables\ConfirmMailing::table(Filament\Tables\Table $table) must be compatible with Filament\Tables\Actions\Contracts\HasTable::table
Am I missing something or is this a bug?
Solution:
Found it, used the wrong
HasTable
HasTable
trait. The correct one is
use Filament\Tables\Contracts\HasTable;
use Filament\Tables\Contracts\HasTable;
...
Jump to solution
1 Reply
Solution
Patrick
Patrick6mo ago
Found it, used the wrong
HasTable
HasTable
trait. The correct one is
use Filament\Tables\Contracts\HasTable;
use Filament\Tables\Contracts\HasTable;
Want results from more Discord servers?
Add your server