I have a navigation bar like this.
<li>Account</li>
<ul>
<li>Register</li>
<li>Login/li>
...
I want to update this dynamically depending on Auth::check()
. For example, if the user is logged in, "Account" will be changed with "My Profile Page" and child siblings will be replaced with an appropriate array.
I need to do this without editing View::make calls
in my controllers. It looks pretty bad.
A solution like this is what I'm looking for;
View::composer('home.*', function($view) {
if(Auth::check())
return $view->nest('accountArea', 'home.navigation-loggedIn', null);
else
return $view->nest('accountArea', 'home.navigation-visitor', null);
});
If there are better alternatives, I would like to hear them too!