title: Lumen how to build serialised structure from models collection?
body: <p>I have few tables in DB, with relations. For example:</p>
  
  <pre><code>user table
  - id
  - name
  - email
  - created_at
  
  orders table
  - id
  - user_id
  - status
  - created_at
  
  order_items table
  - id
  - order_id
  - item_id
  - count
  
  items table
  - id 
  - article
  - name
  - ...
  </code></pre>
  
  <p>And finally I need transform data to this view -
  Orders:</p>
  
  <pre><code>[
    {
      "id": 1,
      "status": "created",
      "user": {"id":1, "name":"Max"},
      "items":[{"id":1, "name":"Banana", "count": 2}, {...item two}]
    },
    {
      .. order two
    }
  ]
  </code></pre>
  
  <p>Some fields will be hidden (created_at, etc), and all models selected with it relations.</p>
  
  <p>So, I can do something like </p>
  
  <pre><code>$userOrders = Orders::where([
      'user_id' =&gt; $request-&gt;user()-&gt;id
  ])
      -&gt;select(['id'])
      -&gt;with('orders.items') // &lt;&lt;&lt;&lt; oops nested relations
      -&gt;get();
  </code></pre>
  
  <p>But problems:</p>
  
  <ol>
  <li>How to select with nested relations</li>
  <li>How to leave only needed fields from nested relations (ideally based on model scenarios when fields list depends on scenario)</li>
  </ol>