dimanche 30 octobre 2016

Automatically pass variable to any view

I'm on Laravel 5.3. I can just pass variable to view by

public function test(){
    $testVar = 'test';

    return view('pages.home',compact('testVar'));
}

How can I automatically pass a variable to view without creating the variable unto the controller and then pass it to the compact argument? like

public function test(){
    return view('pages.home');
}

and then in view, I can just retrieved the variable anywhere in my application, like using the 'Auth::check()'

<div class="menu" id="primary-menu">
    
</div>

any ideas, help please?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire