Distributor Table - id Product Table - id Distributorprocuct Table - distributor_id, product_id
Distributor Model -
public function product() { return $this->hasMany(Distributorproduct::class); }
Product Model -
public function distributor() { return $this->hasMany(Distributorproduct::class); }
Distributorproduct Model -
public function distributor() { return $this->belongsTo(Distributor::class); }
public function product() { return $this->belongsTo(Product::class); }
If I write $product->distributor
then it gives me all the details of distributorproduct but i need the details of distributor not distributorproduct .
If i write $distributor->product
then it gives me all the details of distributorproduct but i need the details of product not distributorproduct .
Thanks in advance...