Reputation: 11
I have a <h1>
tag in my template blade, its duplicate in all pages of my website. I want to do a condition if the page is Homepage then use this <h1>
else don't write it.
This is my header code
<div class="col-sm-7">
<div class="slogan">
<h1 id="h1" class="tlt">my h1 Tag</h1>
<span id="span" class="tlt">" {{$slogan[0]->text}} "</span>
</div>
</div>
Thanks
Upvotes: 1
Views: 6435
Reputation: 2681
You can use Request::is('/')
, given that the "homepage" is on this url. The is()
method can also accept wildcards which can be useful for stuff like Request::is('admin/*');
.
Upvotes: 10
Reputation: 7303
If you have a route name for your routes, you can do like this in your view:
Route:
Route::get('/', ['as'=>'home', 'uses'=>'HomeController@index']);
In view:
@if(request()->route()->getName() == 'home')
// <h1> Text for home page </h1>
@else
//text for other pages.
@endif
Upvotes: 2