title: how to show data of databse in navigation bar on laravel 7
body: <p>i am new to laravel. currently  i am working on laravel 7. i made a navigation bar a seperate file which i extends on all the front end file.  i just  know that when i need a data from the database in front end
  then i do like this</p>
  <pre><code>$cat = modelname::all();
          return view('addproducts')-&gt;with('cat',$cat);
  </code></pre>
  <p>but that code works on that condition when i have to go to that front end blade file. but  on navigation bar senario i dont need to go to the nav file i just go to another  blade file  and nav file is extended on it.
  i just want to know how to access the data from the databse on navigation bar</p>
  <pre><code>&lt;html&gt;
  &lt;head&gt;
      &lt;meta charset=&quot;utf-8&quot;&gt;
  
      &lt;title&gt;{{ config('app.name', 'Laravel') }}&lt;/title&gt;
  
      &lt;!-- Scripts --&gt;
      &lt;script src=&quot;{{ asset('js/app.js') }}&quot; defer&gt;&lt;/script&gt;
  
      &lt;!-- Styles --&gt;
      &lt;link href=&quot;{{ asset('css/app.css') }}&quot; rel=&quot;stylesheet&quot;&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;nav class=&quot;navbar navbar-expand-lg navbar-light bg-light&quot;&gt;
      &lt;a class=&quot;navbar-brand&quot; href=&quot;#&quot;&gt;Navbar&lt;/a&gt;
      &lt;button class=&quot;navbar-toggler&quot; type=&quot;button&quot; data-toggle=&quot;collapse&quot; data-target=&quot;#navbarSupportedContent&quot; aria-controls=&quot;navbarSupportedContent&quot; aria-expanded=&quot;false&quot; aria-label=&quot;Toggle navigation&quot;&gt;
          &lt;span class=&quot;navbar-toggler-icon&quot;&gt;&lt;/span&gt;
      &lt;/button&gt;
  
      &lt;div class=&quot;collapse navbar-collapse&quot; id=&quot;navbarSupportedContent&quot;&gt;
          &lt;ul class=&quot;navbar-nav mr-auto&quot;&gt;
              &lt;li class=&quot;nav-item active&quot;&gt;
                  &lt;a class=&quot;nav-link&quot; href=&quot;{{'addcategory'}}&quot;&gt;Add Catgory &lt;span class=&quot;sr-only&quot;&gt;(current)&lt;/span&gt;&lt;/a&gt;
              &lt;/li&gt;
              &lt;li class=&quot;nav-item&quot;&gt;
                  &lt;a class=&quot;nav-link&quot; href=&quot;{{'showcategory'}}&quot;&gt;show Category&lt;/a&gt;
              &lt;/li&gt;
              &lt;li class=&quot;nav-item dropdown&quot;&gt;
                  &lt;a class=&quot;nav-link dropdown-toggle&quot; href=&quot;#&quot; id=&quot;navbarDropdown&quot; role=&quot;button&quot; data-toggle=&quot;dropdown&quot; aria-haspopup=&quot;true&quot; aria-expanded=&quot;false&quot;&gt;
                      Manage Products
                  &lt;/a&gt;
                  &lt;div class=&quot;dropdown-menu&quot; aria-labelledby=&quot;navbarDropdown&quot;&gt;
                      &lt;a class=&quot;dropdown-item&quot; href=&quot;{{'
                      addproducts'}}&quot;&gt;Add Products&lt;/a&gt;
                      &lt;a class=&quot;dropdown-item&quot; href=&quot;#&quot;&gt;Another action&lt;/a&gt;
                      &lt;div class=&quot;dropdown-divider&quot;&gt;&lt;/div&gt;
                      &lt;a class=&quot;dropdown-item&quot; href=&quot;#&quot;&gt;Something else here&lt;/a&gt;
                  &lt;/div&gt;
              &lt;/li&gt;
              &lt;li class=&quot;nav-item&quot;&gt;
                  &lt;a class=&quot;nav-link disabled&quot; href=&quot;#&quot;&gt;Disabled&lt;/a&gt;
              &lt;/li&gt;
          &lt;/ul&gt;
          &lt;form class=&quot;form-inline my-2 my-lg-0&quot;&gt;
              &lt;input class=&quot;form-control mr-sm-2&quot; type=&quot;search&quot; placeholder=&quot;Search&quot; aria-label=&quot;Search&quot;&gt;
              &lt;button class=&quot;btn btn-outline-success my-2 my-sm-0&quot; type=&quot;submit&quot;&gt;Search&lt;/button&gt;
          &lt;/form&gt;
      &lt;/div&gt;
  &lt;/nav&gt;
  @yield('content')
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <p>this is the code of my nav file where i want to get the data from the database and then  want to show in a dropdown menu</p>
  <pre><code>@extends('layouts.nav');
  @section('content')
      //code for the front end of the page
      @endsection
  </code></pre>
  <p>this is how i extend the nav file on another page</p>