I'm struggling to get the view name in L5. Just as in WP, I'd like to add a specific page name (view name) for styling, like so:
<!-- View name: login.blade.php !-->
<div id="page" class="page-login">
<h1>Inloggen</h1>
</div>
<!-- View name: register.blade.php !-->
<div id="page" class="page-register">
<h1>Registreren</h1>
</div>
In L4 it can be done using composer to share the var across all views (How can I get the current view name inside a master layour in Laravel 4?). But I only need the view name once for my master layout.
Doing this:
<div id="page" class="page-{{ view()->getName() }}">
Gives me the following error Call to undefined method IlluminateViewFactory::getName()
.
Thanks in advance!
See Question&Answers more detail:os