title: How to make multiple objects of json - using laravel
body: <p>I want to make objects in my json response i have achieved this functionality but i want to do more in my response the response currently i am getting is:</p>
  
  <pre><code>"privileges": {
      "facilities": [
      {
          "facility_id": 1,
          "speciality_id": 1,
          "is_facility_supervisor": 1
      },
      {
          "priv_key": "ced"
      }
      ]
  }
  </code></pre>
  
  <p>But i want to add "priv_key": "ced" into my facilities object and one thing more i want to add "is_super_admin": 1. into "privileges like below:</p>
  
  <pre><code>"privileges": { 
      "is_super_admin": 1,
      "facilities": [
      {
          "facility_id": 1,
          "speciality_id": 1,
          "is_facility_supervisor": 1
      },
      {
          "priv_key": "ced"
      }
      ]
  }
  </code></pre>
  
  <p>How i can achieve above functionalities this is is my controller code:</p>
  
  <pre class="lang-php prettyprint-override"><code>$response = array(); 
  $response['facilities'] = DB::table('users')-&gt;where('is_super_admin')-&gt;first();
  $response['facilities'][0] = DB::table('user_facility')-&gt;select('user_facility.facility_id','user_facility.speciality_id','user_facility.is_facility_supervisor')-&gt;where('user_id',$currentUser-&gt;id)-&gt;first();
  $response['facilities'][1] = DB::table('prev_definition')-&gt;select('prev_definition.priv_key')-&gt;where('user_id',$currentUser-&gt;id)-&gt;first();
  </code></pre>
  
  <p>and my login where i am sending response:</p>
  
  <pre class="lang-php prettyprint-override"><code>return response()-&gt;json([
      'status' =&gt; true,
      'message' =&gt; 'Login successfully',
      'data' =&gt; [
          'privileges' =&gt; $response
      ]
  ]);
  </code></pre>
  
  <p>I dont have idea how to implement the above functionalities anyone there please help me your help will be highly appreciated!</p>