title: Laravel Query 4 table
body: <p>I list my orders and I list the total number of these orders. Can you help me how to specify the order color I want?</p>
  <p>controller code;</p>
  <pre><code>$orders = Order::select('order.*', 'order_piece.*', DB::raw('SUM(order_piece.piece) As piece'))
          -&gt;Join('order_piece', 'order_piece.order_id', '=', 'order.id')
          -&gt;where('order.collection_id', $request-&gt;model_id)
          -&gt;groupBy('order_piece.order_id')
          -&gt;get();
  </code></pre>
  <p>database design;<a href="https://i.stack.imgur.com/3Hv9j.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3Hv9j.png" alt="enter image description here" /></a></p>