title: convert json array to json object in laravel 5.7
body: <p>I am getting data from database using join query in <code>laravel</code> &amp; pass to <code>json</code> and getting some result in array but I want object that I given below</p>
  
  <p>Controller code:</p>
  
  <pre><code>$resultPastActivity= DB::table('table_user_create_activity')
                              -&gt;join('table_sub_category','table_user_create_activity.selected_activity_id', '=', 'table_sub_category.sub_category_id')
                              -&gt;select('sub_category_name','area','activity_type','activity_date','start_time','end_time')
                              -&gt;whereDate('activity_date', '&lt;', $todayDate)
                              -&gt;where('user_id',$user_id)
                              -&gt;get();
  
   return response()-&gt;json(['success' =&gt; '1','data' =&gt;$resultPastActivity]);
  </code></pre>
  
  <p>The above code will give following json that is in array actually i want json in object</p>
  
  <pre><code>{
      "success": "1",
      "data": [
          {
              "sub_category_name": "Badminton",
              "area": "Rankala lake",
              "activity_type": "1",
              "activity_date": "2018-01-12",
              "start_time": "15:04:49",
              "end_time": "20:05:69"
          },
          {
              "sub_category_name": "Football",
              "area": "Devakar panad",
              "activity_type": "1",
              "activity_date": "2018-01-15",
              "start_time": "15:04:49",
              "end_time": "20:05:69"
          },
      ]
  }
  
  
  
  i want json as follows
  {
      "success": "1",
      "data": {
          {
              "sub_category_name": "Badminton",
              "area": "Rankala lake",
              "activity_type": "1",
              "activity_date": "2018-01-12",
              "start_time": "15:04:49",
              "end_time": "20:05:69"
          },
          {
              "sub_category_name": "Football",
              "area": "Devakar panad",
              "activity_type": "1",
              "activity_date": "2018-01-15",
              "start_time": "15:04:49",
              "end_time": "20:05:69"
          },
      }
  }
  </code></pre>