I'm starting a project php with Laravel framework 5!
I need to make a section in my project laravel for a dashboard to know which page is visited by the user.
Example: Menu Dashboard [Home -> Profile -> Settings -> Account ]
And i need know what is visited and show to user: ex: Dashboard -> Home
The question is, I use the Blade template of laravel to maker my fixed layout page and use for the other views pages. how to know which view is being accessed to mark in my blade layout?
<html>
<head>
<title>DashBoard</title>
</head>
<body>
@section('sidebar')
<section id="breadcrumb">
<div class="container">
<ol class="breadcrumb">
<li><a href="dashboard.html">Dashboard</a></li>
<li><a href="profile.html">Profile</a></li>
<li><a href="settings.html">Settings</a></li>
<li><a href="account.html">Account</a></li>
</ol>
</div>
</section>
@show
<div class="container">
@yield('content')
</div>
</body>
</html>
You can check the url/route using the Request::is()
function, so setting something like:
<li class="{{ Request::is("dashboard") ? "active" : "" }}">
<a href="dashboard.html">Dashboard</a>
</li>
...
To set one of your <li>
items as active
, which you'd then just style slightly different than non-active ones.
Note that the value passed to is()
has to match the way you have the route defined in routes.php
: (Note: Omit leading /
in is()
)
Route::get("/dashboard", ...);
...