F
Filament13mo ago
Samir

Attach in relationship manager is Timing out

Admin panel has Product and Seller resources with a many-to-many relationship. Sellers, treated as authenticatable users, can't create products but can select/add from Admin's product list. Admin's relationship manager works well. In Seller Resource, Admin can view/edit a seller and manage their products efficiently. However, attaching products is slow. In the Seller panel, the user can view their products but faces timeouts in attaching due to slow select searches, even with preload implementation. In Seller Panel, I have created a Filament Custom page called Products and add below code in the component. Below is the code. What is wrong.
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(),
]),
]);
}

}
I dont get any error while while viewing my record as a Seller in my Seller panel. I can detach if admin panel has added products for me. Please help.
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server