title: Laravel, Products with Attributes in a many-to-many table
body: <p>I'm building a platform where Suppliers can add products, and shop owners can 'copy' those products to their shops and sell them.</p>
  
  <p>A Supplier can create products, and he can add all sorts of attributes to them, like the size, colors.</p>
  
  <p>When a Shop wants to use one of the Supplier's products, he can choose which attributes he wants to offer. For example if the Supplier has a T-Shirt in offer with 3 sizes. The shop may choose to sell that T-Shirt with only 2 sizes.</p>
  
  <p>So I have a <strong>Products</strong> table which looks like this. The Supplier adds products in here.</p>
  
  <pre><code>+----+-------------+-------+
  | id | description | price |
  +----+-------------+-------+
  |  1 | T-Shirt     |    10 |
  |  2 | Car         |   100 |
  +----+-------------+-------+
  </code></pre>
  
  <p>I have a Product attributes table, Which is also filled by the Supplier</p>
  
  <pre><code>+------------+-------------+------------------------------+
  | product_id | description |           options            |
  +------------+-------------+------------------------------+
  |          1 | size        | ["small", "medium", "large"] |
  |          1 | color       | ["white", "black"]           |
  +------------+-------------+------------------------------+
  </code></pre>
  
  <h2>Shop Side</h2>
  
  <p>When a Shop owner wants a Product. I make a record in the shop_products table, referencing which Shop wants what Product, and adding an optional image, as following</p>
  
  <pre><code>+---------+------------+-----------+
  | shop_id | product_id |   image   |
  +---------+------------+-----------+
  |       1 |          2 | image.jpg |
  |       1 |          3 | image.jpg |
  +---------+------------+-----------+
  </code></pre>
  
  <blockquote>
    <p>Now the only issue remaining is: How do I make sure the Shop can choose which attributes he wants to take.</p>
  </blockquote>
  
  <ul>
  <li>Should I create a shop_product_attributes table.. But I can't put a relation on the many-to-many because it doesn't have an id?</li>
  </ul>