title: laravel share variable across all methods in a controller
body: <p>i am making a simple website in PHP laravel framework where the top navigation links are being generated dynamically from the database. I am generating the $pages variable in the home controller action and passing to layout file. My code is as below:</p>
  
  <pre><code> public function home()
  {
      $pages = Page::all();
      return View::make('home')-&gt;with('pages', $pages);
  }
  
  public function login()
  {
      return View::make('login');
  }
  </code></pre>
  
  <p>But when i try to access the login action, i get the error variable $pages not found since the $pages variable is being accessed in layout file. How  can i share the same variable across all the actions in a controller?</p>