Alaikum-salaam
Create a model for product_attribute_values, it would be called ProductAttributeValue.
Then create a resource for that model that accept the three value for product, attributes and attribute values IDs
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
salam-alaikum
I am working on the project by laravel nova and I can't insert data into Pivot table.
let me describe what my problem is.
I have 4 tables.
1- product
2- attributes
3- attribute_values
4 - product_attribute_values - ( Pivot table )
After that, I make Resource (AttributeValues) by Nova to insert the value of attribute into (attribute_values) and the same Resource I insert data into product_attribute_values - ( Pivot table ). Actually, I can insert product_id and attribute_values_id into product_attribute_values but I can't insert attribute_id
this is my Resource.
public function fields(NovaRequest $request) {
return [
ID::make()->sortable(),
Text::make('name')->showWhenPeeking()
->sortable()
->rules('required', 'max:255'),
Text::make('description')
->sortable()
->rules('required', 'max:5000'),
BelongsTo::make('Attribute'),
Multiselect::make('Product','ProductAttributeValue')
->options(\App\Models\Product::pluck('title', 'id'))
->belongsToMany(\App\Nova\Product::class),
];
}
Please or to participate in this conversation.