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');
}
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');
}
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'),
]);
}
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'),
]);
}
1 Reply
Shaung Bhone
Shaung BhoneOP10mo ago
public function up(): void
{
Schema::create('attribute_sku', function (Blueprint $table) {
$table->id();
$table->foreignIdFor(Attribute::class)
->constrained()
->cascadeOnDelete();
$table->foreignIdFor(Sku::class)
->constrained()
->cascadeOnDelete();
$table->string('value')
->comment('The value for this SKU and attribute combination, i.e. Small, Red, etc.');
$table->timestamps();
});
}
public function up(): void
{
Schema::create('attribute_sku', function (Blueprint $table) {
$table->id();
$table->foreignIdFor(Attribute::class)
->constrained()
->cascadeOnDelete();
$table->foreignIdFor(Sku::class)
->constrained()
->cascadeOnDelete();
$table->string('value')
->comment('The value for this SKU and attribute combination, i.e. Small, Red, etc.');
$table->timestamps();
});
}
Want results from more Discord servers?
Add your server