Laravel: passing a variable to multiple views
<p>I would like to make the menu dinamically, so instead showing "FILMS OF THE MONTH" it shows "FILMS OF DECEMBER" (see the image); being December the current month that update itself each month</p>

<p>My problem is that the menu does not belongs to an specific route/controller, therefore I can not pass the variable like I do with other routes. Example: </p>

<pre><code>    $month = Carbon::now()-&gt;format('F');
    return view('partials._nav')
            -&gt;withMonth($month);
</code></pre>

<p>I could "solve" that problem passing the month to ALL controllers/routes, but I am repeating many times the same code.</p>

<p><strong>My questions are</strong></p>

<p>1- Is there any way in Laravel to pass a variable to a kind of rootstate (like in Angular) so, I keep the variable available in All routes of my application?</p>

<p>2- Is there any way that I could return a variable to more than one view? So I just pass the variable to all views possible like:</p>

<pre><code>return view('films.all', 'films.show', 'films.index', 'actors.show', 'actors.index')
                -&gt;withMonth($month);
</code></pre>

<p>Any idea would be appreciated</p>

<p><a href="https://i.stack.imgur.com/Gudjz.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Gudjz.jpg" alt="The navigation is outside the scope of views"></a>
<strong>UPDATE</strong></p>

<p><a href="https://i.stack.imgur.com/PW1hG.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PW1hG.jpg" alt="The menu is outside the views scope"></a></p>

<p><strong>Finally I have the solution:</strong></p>

<pre><code>public function boot()
{
    View::composer('*', function ($view) {
        $month = Carbon::now()-&gt;format('F');

        $view-&gt;withMonth($month);
    });
}
</code></pre>