Skip to content

Instantly share code, notes, and snippets.

@davidtrushkov
Created December 21, 2016 22:32
Show Gist options
  • Star 17 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save davidtrushkov/a8bdb87227db23b147ddc22136ebc330 to your computer and use it in GitHub Desktop.
Save davidtrushkov/a8bdb87227db23b147ddc22136ebc330 to your computer and use it in GitHub Desktop.
Make Bootstrap Carousel Dynamic - Laravel 5.3
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
@foreach( $trip->photos as $photo )
<li data-target="#carousel-example-generic" data-slide-to="{{ $loop->index }}" class="{{ $loop->first ? 'active' : '' }}"></li>
@endforeach
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
@foreach( $trip->photos as $photo )
<div class="item {{ $loop->first ? ' active' : '' }}" >
<img src="{{ $photo }}" alt="{{ $trip->listing->name }}">
</div>
@endforeach
</div>
<!-- Controls -->
<a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
@guillermoprojaslema
Copy link

Thank you. This was very helpfull

@ahmadshobirin
Copy link

Thank you. This was very helpfull

@rrosete
Copy link

rrosete commented Aug 25, 2017

Thank you.

@QusaiFarraj
Copy link

Thank you.

@UnforgivenHobbies
Copy link

Thanks!!!

@vivekraj12
Copy link

i am new to laravel and website development .will you please tell me where we have to keep the file ,in laravel directory ,and where we have to keep our image

@ppoussane
Copy link

thank you

@mahbubkhan88
Copy link

Thanks bro

@easyguyme
Copy link

Thanks so much

@hash9211
Copy link

thanks a lot

@Akshaypatwari
Copy link

Thank you

@toeurtenh
Copy link

amazing

@menakeno
Copy link

menakeno commented Apr 1, 2019

Thank you

@pratika2395
Copy link

@davidtrushkov, slider is working but next, prev buttons are not visible

@lss007
Copy link

lss007 commented Feb 4, 2021

Nice

@hatwell-jonel
Copy link

Thank you!!!

@babamurad
Copy link

Thank you!

@Chuby399
Copy link

what does the $loop->first mean because that part is confusing me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment