title: How to load variables to the views in more than 1 routes in laravel
body: <p>I am using laravel 5.4 and I have an admin panel which has many routes and the application itself has many routes. </p>
  
  <p>For all the admin panel routes, I needed a variable to load on every views of the admin so I used a service provider and returning that variable to the view like this.</p>
  
  <pre><code>view()-&gt;composer('*', function ($view)
      {
          /*total unseen contacts*/
              $contact= DB::table('contacts')
                   -&gt;select(DB::raw('count(status) as cont'))
                   -&gt;where('status', '=', 0)
                   -&gt;orderBy('id', 'desc')
                   -&gt;get();
  
          $view-&gt;with('contact', $contact);
      });
  </code></pre>
  
  <p>and this works fine but the problem is this query also runs in the main application where there is no need for this query at all. </p>
  
  <p>So the question is how can I separate admin routes and application routes? Please let me know if there are any other better ways to do so.</p>
  
  <p>Thank you.</p>