Creating with pivot attributes

I can't create pivot
value
when creating sku.

Sku.php

public function attributes(): BelongsToMany
{
    return $this->belongsToMany(Attribute::class, 'attribute_sku')->withPivot('value');
}

Attribute.php

public function skus(): BelongsToMany
{
    return $this->belongsToMany(Sku::class, 'attribute_sku')->withPivot('value');
}

SkusRelationManager.php

public function form(Form $form): Form
{
    return $form
        ->schema([
            Forms\Components\TextInput::make('sku')
                ->required()
                ->maxLength(255),
            Forms\Components\Select::make('attribute_sku')
                ->relationship('attributes', 'name'),
            Forms\Components\TextInput::make('value'),
        ]);
}
Was this page helpful?