Solution:
You may try something like the following when declaring the relationship method in your models:
// Product.php
protected $primaryKey = 'product_uuid';
public function options()
{
return $this
->belongsToMany('App\Option', 'product_option', 'product_uuid', 'option_uuid');
}
// Option.php
protected $primaryKey = 'option_uuid';
public function products()
{
return $this
->belongsToMany('App\Product', 'product_option', 'option_uuid', 'product_uuid');
}
Differentiate promary key names in both tables, use (product_uuid
and option_uuid
) otherwise you’ll fall in more trouble.