Reputation: 251
I want to hide an icon if the link is empty. Here is the <a>
tag with <i>
tag for Instagram. If the field from admin is empty, I want to hide it. I'm using the Laravel framework.
<a href="https://instagram.com/{{ $model->instagram }}"><i class="fa fa-instagram"></i> {{ $followed_by }}</a>
Do you have any ideas?
Thanks.
Upvotes: 2
Views: 419
Reputation: 1410
You can use @if
blade directive:
@if ($model->instagram)
<a href="https://instagram.com/{{ $model->instagram }}">
<i class="fa fa-instagram"></i> {{ $followed_by }}
</a>
@endif
Depending on your Laravel version you might also have @isset
/@empty
directives available for you. You can read more about it in official documentation.
Upvotes: 4
Reputation: 1373
Use Blade @if
Statement.
Simply Write like below code:-
@if(!empty($model->instagram))
<a href="https://instagram.com/{{ $model->instagram }}"><i class="fa fa-instagram"></i> {{ $followed_by }}</a>
@endIf
That's It.
You can read about more laravel Blade from here
Upvotes: 1