lundi 26 octobre 2015

Working with pivot table to access other table information

I have two tables: products and requests, a pivot ** requests_products** that save the products_id, requests_id and other two informations.

I also have another table called requests_observations that save the requests_products_id and an observation for that product in that request.

In my Requests model I have a belongsToMany to Products

/**
 * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
 */
public function products()
{
    return $this->belongsToMany('App\Products', 'requests_products')->withTimestamps();
}

But what I need to do is to add an observation for a requests_products_id, I have a model for this table, but I don't know where I put the hasMany, in Products or Requests model.

Thank you.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire