title: Get data from relationship using Eloquent
body: <p>I am trying to get data from Menu and SubMenu table using Eloquent model instead of join.</p>
  
  <p>My Menucontroller</p>
  
  <pre><code>class MenuController extends Controller
  {
  // Where ever you want your menu
      public function menu()
      {
  
          $menu = Menu::all()-&gt;load('submenu');
  
      return view('menu',compact('menu'));
      }
  }
  </code></pre>
  
  <p>My menu Model is </p>
  
  <pre><code>use Illuminate\Database\Eloquent\Model;
  class Menu extends Model
  {
  
  
      public function submenu()
      {
          return $this-&gt;hasMany(SubMenu::class);
      }
  }
  </code></pre>
  
  <p>My submenu model is </p>
  
  <pre><code>use Illuminate\Database\Eloquent\Model;
  class SubMenu extends Model
  {
      public function menu()
      {
          return $this-&gt;belongsTo(Menu::class);
      }
  }
  </code></pre>