title: Global variable in laravel controller
body: <p>I want the <code>$year</code> variable to be available in all functions of my <code>PagesController</code>. I tried this code but I didn't succeed.  </p>
  
  <pre class="lang-php prettyprint-override"><code>class PagesController extends Controller
  {
      public function __construct()
      {
          $dt = Carbon::parse();
          $year = $dt-&gt;year;
      }
  
      public function index()
      {
          return view('pages.index');
      }
  
      public function about()
      {
          return view('pages.about', compact('year'));
      }
  
      public function create()
      {
          return view('pages.create', compact('year'));
      }
  }
  </code></pre>