FilamentF
Filament11mo ago
Alex'R

Edit RelationManager pivot array data

Hi,

I'm trying to create a form to update my pivot table data for a resale system.

I have, in my Model Service, my relationship which includes the pivots:

    public function providers(): BelongsToMany
    {
        return $this->belongsToMany(Provider::class, 'provider_services')
            ->using(ProviderServicePivot::class)
            ->withPivot('extra', 'is_enabled')
            ->withTimestamps();
    }


And this is my ProviderServicePivot :

class ProviderServicePivot extends Pivot
{
    public function casts(): array
    {
        return [
            'extra' => 'array',
            'is_enabled' => 'boolean',
        ];
    }
}


And on my form when i Try to access on extra.name property, it doesn't work.

    public function form(Form $form): Form
    {
        return $form
            ->schema([
                Forms\Components\Section::make(__('inputs.sections.infos'))
                    ->columns(2)
                    ->schema([
                        Forms\Components\TextInput::make('extra.name')
                           ->label(__('inputs.generic.name'))
                           ->maxLength(255)
                           ->required()
                    ]),
            ]);
    }


Anyone have an idea of ​the method to follow?

Thank you so much,
Solution
I've found solution. I need to mount my EditAction with pivot to array
Was this page helpful?