i'm trying to create a simple relationship between tables :
- attribute_products -
id
name
- products -
id
name
price
pivot table to link them :
- attribute_product_value -
attribute_type_id
value
product_id
Products Model
public function attributeProduct(){
return $this->belongsToMany(AttributeProduct::class,'attribute_product_values','product_id','attribute_id');
}
attribute_products model
public function product()
{
return $this->belongsToMany(Product::Class,'attribute_product_values','attribute_id','product_id');
}
how can I get the "value" field from the pivot table (product to "value")?