What's your data look like? Can you post some code?
Jun 11, 2019
10
Level 1
Display specific images with captions
I want to display only those images in the carousel which have captions and not those which have no captions.
I was thinking of using if function and check if the incoming image has the caption or not, but I don't know how to do it. is there any other way of doing it?
plz, help me cuz I am new to this.
Level 122
here is a tip for this forum
ignore anything @munazzil tells you
@foreach ($packages as $key => $package)
@if( $package->caption)
<div class="carousel-item{{ $key == 0 ? ' active' : '' }}">
<img class="d-block w-100" src="{{ Storage::disk('local')->url('img/package/' . $package->image) }}">
<div class="carousel-caption d-none d-md-block">
<div class="container">
{!! $package->caption !!}
<a class="button-theme" href="{{ route('travel.itinerary', $package->slug) }}">learn more</a>
</div>
</div>
</div>
@endif
@endforeach
and never use {!! !!} unless you REALLY know what you are doing and have previously sanitized the data
2 likes
Please or to participate in this conversation.