title: Laravel Nested Query for Phone Brand and Phone Model from 2 tables
body: <p><a href="https://i.stack.imgur.com/CnhNf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CnhNf.png" alt="phone_brands" /></a></p>
  <p><a href="https://i.stack.imgur.com/I0OOw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/I0OOw.png" alt="phone_models" /></a></p>
  <p>I have 2 tables
  1st) Brand Name of Mobile phone
  2nd) - Model Name for Brand Name</p>
  <p>How can i get output like below. I need JSON output as i am creating dropdown button in Android (Flutter) App based on nested inputs</p>
  <pre><code>{
        &quot;phone_brand_name&quot;: &quot;Apple&quot;,
        &quot;phone_brand_model_name&quot;: [
          &quot;Apple iPhone 11&quot;,
          &quot;Apple iPhone 11 Pro&quot;,
          &quot;Apple iPhone 11 Pro Max&quot;,
        ]
      },
  </code></pre>
  <p>I have below hasMany relation :</p>
  <pre><code>class PhoneBrand extends Model
  {
      
      public function phoneModels()
      {
          return $this-&gt;hasMany('PhoneModelsController');
      }
      
  }
  </code></pre>