title: Joining two tables in laravel - how to have second table data as a property of result
body: <p>I have two tables A and B.</p>
  
  <p>Table A:</p>
  
  <pre><code>no  name  type
  1   shoe   1
  2   shirt  2
  3   book   3
  </code></pre>
  
  <p>Table B:</p>
  
  <pre><code>type color   size
  1    red     big
  2    yellow  small
  3    blue    medium
  </code></pre>
  
  <p>When I query <code>where A.no === 1 and A.type === 1</code>, I want to get data like:</p>
  
  <pre><code>{
    no: 1,
    name: 'shoe',
    type: 1,
    info: {
      color: 'red',
      size: 'big'
    },
  }
  </code></pre>
  
  <p>I tried something like this: </p>
  
  <pre><code>select a.*, b.* from stores a, types b where a.type = 1 and a.type = b.id
  </code></pre>
  
  <p>and it returns only plain object, I want to get nested data like the above.
  I  think it can be done using join and doing any other query tricks.</p>
  
  <p>Here's the sql fiddle link I prepared for you.
  <a href="http://sqlfiddle.com/#!9/3ad910/2" rel="nofollow noreferrer">http://sqlfiddle.com/#!9/3ad910/2</a></p>
  
  <p>Thanks in advance.</p>