FilamentF
Filament3y ago
ouch

Many to Many in Tables in livewire component

Hey guys I'm newbie in filament and livewire and I'm confused with relationships.
I have filament tables as stand alone package on livewire without panel, and i have a problem with many to many relationship Order >--< Status, and I want to use SelectColumn.

And I'm confused how to make it work. Because i dont use panel so i can't create realation ship manager correct?

Model Order
    public function statuses(): BelongsToMany
    {
        return $this->belongsToMany(
            Status::class,
            'order_status',
            'order_id',
            'status_id'
        )->withTimestamps();
    }

Inside table - I know that it does not get last element but honestly I'm lost now.
SelectColumn::make('statuses.name')
            ->label('Stav')
            ->options(Status::pluck('name')
            ->toArray())
Was this page helpful?