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!
View::composer('layouts.default', ...)
. – SoftwareView::composer('home.layout', ...)
does automatically bind all the content files yielding on defined layout? Also I want to ask one more thing. (similar question) How do the people using Laravel handle 'always has to be binded' things like'<title>{{ $title }}</title>'
. Is there any good-practice uses I can have a look at? – Allo