dimanche 30 octobre 2016

Automatically pass variable to any view [duplicate]

This question already has an answer here:

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?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2e2TR1f
via IFTTT

Aucun commentaire:

Enregistrer un commentaire