title: Set name in json format in php/laravel
body: <p>How to set name to JSON object in laravel as I want to display for a plugin in Vue js for image gallery. Whenever I pass data I Got this error : Expected Object, got Array. </p>
  
  <pre><code>{
    "normal_size": [
      {
        "id": 1,
        "image": "MICMIMC30651-6.jpg",
        "url": "http://localhost:8000/images/product/preview/MICMIMC30651-6.jpg"
      },
      {
        "id": 2,
        "image": "MICMIMC30651-61.jpg",
        "url": "http://localhost:8000/images/product/preview/MICMIMC30651-61.jpg"
      },
      {
        "id": 3,
        "image": "MICMIMC30651-62.jpg",
        "url": "http://localhost:8000/images/product/preview/MICMIMC30651-62.jpg"
      },
      {
        "id": 4,
        "image": "MICMIMC30651-63.jpg",
        "url": "http://localhost:8000/images/product/preview/MICMIMC30651-63.jpg"
      }
    ]
  
  }
  </code></pre>
  
  <pre>output I wanted : </pre>
  
  <pre><code>image : {
    "normal_size": [
      {
        "id": 1,
        "image": "MICMIMC30651-6.jpg",
        "url": "http://localhost:8000/images/product/preview/MICMIMC30651-6.jpg"
      },
      {
        "id": 2,
        "image": "MICMIMC30651-61.jpg",
        "url": "http://localhost:8000/images/product/preview/MICMIMC30651-61.jpg"
      },
      {
        "id": 3,
        "image": "MICMIMC30651-62.jpg",
        "url": "http://localhost:8000/images/product/preview/MICMIMC30651-62.jpg"
      },
      {
        "id": 4,
        "image": "MICMIMC30651-63.jpg",
        "url": "http://localhost:8000/images/product/preview/MICMIMC30651-63.jpg"
      }
    ]
  
  }
  </code></pre>
  
  <p>`</p>
  
  <h2>Laravel product controller code to pass data to vue component</h2>
  
  <pre><code> $normal_size = DB::table('products_images')-&gt;where([['products_id', '=', $product]])
          -&gt;select('products_images.id','products_images.image')
          -&gt;get()-&gt;ToArray();
  
  foreach($normal_size as $value)
          {
              $value-&gt;url = 'http://localhost:8000/images/product/preview/'.$value-&gt;image;
          }
  $output = (array('normal_size' =&gt; $normal_size));
  return response()-&gt;json(($output));
  </code></pre>