I am using Laravel 4. I would like to access the current URL inside an @if
condition in a view using the Laravel\'s Blade templating engine but I don\'t know ho
You will get the url
by using the below code.
For Example your URL like https//www.example.com/testurl?test
echo url()->current();
Result : https//www.example.com/testurl
echo url()->full();
Result: https//www.example.com/testurl?test
@if(request()->path()=='/path/another_path/*')
@endif
You can also use Route::current()->getName()
to check your route name.
Example: routes.php
Route::get('test', ['as'=>'testing', function() {
return View::make('test');
}]);
View:
@if(Route::current()->getName() == 'testing')
Hello This is testing
@endif
Maybe you should try this:
<li class="{{ Request::is('admin/dashboard') ? 'active' : '' }}">Dashboard</li>
class="nav-link {{ \Route::current()->getName() == 'panel' ? 'active' : ''}}"
Try This:
<li class="{{ Request::is('Dashboard') ? 'active' : '' }}">
<a href="{{ url('/Dashboard') }}">
<i class="fa fa-dashboard"></i> <span>Dashboard</span>
</a>
</li>