title: JSON data from two tables without repeating joined table primary key
body: <p>I have two models:</p>
  
  <p><code>Category</code> Model has: <code>id PRIMARY_KEY</code>, <code>category_name</code>, <code>...</code></p>
  
  <p><code>Item</code> Model has: <code>id PRIMARY_KEY</code>, <code>item_name</code>, <code>category_id</code> (is id on category table),   <code>...</code></p>
  
  <p>I wish to achieve this JSON response:   </p>
  
  <pre><code>Item:
  {
      "id": 1,
      "item_name": "some item name",
      "category": {
          "id": "5",
          "category_name": "some category name"
      }
  }
  </code></pre>
  
  <p>So far I have managed to achieve only response:</p>
  
  <pre><code>{
      "id": 1,
      "item_name": "some item name",
      "category_id": "5", // i dont want it to appear here!
      "category": {
          "id": "5",
          "category_name": "some category name"
      }
  }
  </code></pre>
  
  <p>With query:</p>
  
  <pre><code>$data = Item::select('id', 'item_name', 'category_id')-&gt;with(['category' =&gt; function ($query) {
              $query-&gt;select('id', 'category_name');
          }])-&gt;get();
  return response()-&gt;json($data);
  </code></pre>
  
  <p>I tried <code>select('id', 'item_name')</code> instead of <code>select('id', 'item_name', 'category_id')</code>, but it fails, since it required 'category_id' for <code>with</code> to work. Any clean solutions to this?</p>