title: Eloquent Model for pivot table with 3 foreign keys?
body: <p>I am working on a project with has this kind of an model.</p>
  
  <p>A vendor's table to store all vendor details - A vendor is like a company that offers some service.</p>
  
  <p><strong>vendor</strong></p>
  
  <pre><code>id  | name
  ----+-------
   1  | abc 
   2  | def
  </code></pre>
  
  <p>Then I have a Services table which contains the list of all the services that a vendor can offer:</p>
  
  <p><strong>service</strong></p>
  
  <pre><code>id | name
  ---+----------------
  1  |  abc
  2  |  def
  3  |  ghi
  </code></pre>
  
  <p>And there is an area table which contains the list of all the areas from which vendor's can chose if they want to provide service in that area or not.</p>
  
  <p><strong>Areas</strong></p>
  
  <pre><code>id | name
  ---+------
  1  | abc
  2  | def
  3  | ghi
  </code></pre>
  
  <p>Now I want to have a pivot table that stores the details of which vendor provides which service in which area and at what price so my pivot table structure is like this: </p>
  
  <pre><code>vendor_id  | service_id | area_id | price 
  -----------+------------+---------+---------
     1       |    1       |    2    |   25.00
     1       |    1       |    1    |   24.00
     2       |    1       |    1    |   23.00
  </code></pre>
  
  <p>and so on ...</p>
  
  <p>So, now I have 3 different eloquent models for areas services and vendors; however, as the pivot table contains 3 foreign keys, I am unable to update the pivot table properly each time a vendor changes his preferences.</p>
  
  <p>Can you please suggest me the way to define relationship in this scenario or should I change my table structure to store this data?</p>