Answers for "nested for loop in laravel blade"

PHP
2

how to write for loop in laravel blade

<div>
    @for ($i = 0; $i < $max; $i++) //Where $max is whatever you need as break condition.
        <p>{{ $i }}</p> //This would print $i in a paragraph. You do whatever you need here.
    @endfor
</div>
Posted by: Guest on June-22-2020
2

laravel for loop

@for ($i = 0; $i < 10; $i++)
    The current value is {{ $i }}
@endfor

@foreach ($users as $user)
    <p>This is user {{ $user->id }}</p>
@endforeach

@forelse ($users as $user)
    <li>{{ $user->name }}</li>
@empty
    <p>No users</p>
@endforelse

@while (true)
    <p>I'm looping forever.</p>
@endwhile
Posted by: Guest on October-12-2020
0

how to use for foreach loop in carousel in laravel blade

<div id="carouselExampleControls" class="carousel slide" data-ride="carousel">

  <ol class="carousel-indicators">
   @foreach( $photos as $photo )
      <li data-target="#carouselExampleIndicators" data-slide-to="{{ $loop->index }}" class="{{ $loop->first ? 'active' : '' }}"></li>
   @endforeach
  </ol>

  <div class="carousel-inner" role="listbox">
    @foreach( $photos as $photo )
       <div class="carousel-item {{ $loop->first ? 'active' : '' }}">
           <img class="d-block img-fluid" src="{{ $photo->image }}" alt="{{ $photo->title }}">
              <div class="carousel-caption d-none d-md-block">
                 <h3>{{ $photo->title }}</h3>
                 <p>{{ $photo->descriptoin }}</p>
              </div>
       </div>
    @endforeach
  </div>
  <a class="carousel-control-prev" href="#carouselExampleControls" role="button" data-slide="prev">
    <span class="carousel-control-prev-icon" aria-hidden="true"></span>
    <span class="sr-only">Previous</span>
  </a>
  <a class="carousel-control-next" href="#carouselExampleControls" role="button" data-slide="next">
    <span class="carousel-control-next-icon" aria-hidden="true"></span>
    <span class="sr-only">Next</span>
  </a>
</div>
Posted by: Guest on September-11-2020
0

forach in larvel blade

@forelse ($array as $element)
    // loop here
@empty
	// is empty
@endforelse
Posted by: Guest on March-12-2021

Browse Popular Code Answers by Language