class Products extends Page implements HasForms, HasTable
{
use InteractsWithTable;
use InteractsWithForms;
protected static string $view = 'filament.seller.pages.products';
public Seller $seller;
public function mount(Seller $seller): void
{
$seller = Filament::auth()->user();
$this->seller = $seller;
}
public function table(Table $table): Table
{
return $table
->relationship(fn (): BelongsToMany => $this->seller->products())
->inverseRelationship('sellers')
->columns([
Tables\Columns\TextColumn::make('name’),
————other table columns ———
])
->headerActions([
Tables\Actions\AttachAction::make()
->preloadRecordSelect(),
])
->actions([
Tables\Actions\DetachAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DetachBulkAction::make(),
]),
]);
}
}
class Products extends Page implements HasForms, HasTable
{
use InteractsWithTable;
use InteractsWithForms;
protected static string $view = 'filament.seller.pages.products';
public Seller $seller;
public function mount(Seller $seller): void
{
$seller = Filament::auth()->user();
$this->seller = $seller;
}
public function table(Table $table): Table
{
return $table
->relationship(fn (): BelongsToMany => $this->seller->products())
->inverseRelationship('sellers')
->columns([
Tables\Columns\TextColumn::make('name’),
————other table columns ———
])
->headerActions([
Tables\Actions\AttachAction::make()
->preloadRecordSelect(),
])
->actions([
Tables\Actions\DetachAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DetachBulkAction::make(),
]),
]);
}
}