I’m trying to create UI for cinema seats in laravel blade. i have seat_rows and seat_coulmns in my database and seat_rows will be the same for 2 rows. i mean first row is like this: id:1 seat_row:1 seat_column:1 and second row is like this: id:2 seat_row:1 seat:column:2. so i using bootstrap row and col classes and i wanna add row class only when number of seat_row changes. how can I DO that?
@foreach ($allseats as $seat)
JavaScript
x
{{-- @while ($seat->seat_row !== $seat->seat_row) --}}
<div id="{{$seat->seat_row}}" class="row ">
{{-- @for ($i = 1; $i <= 2; $i++) --}}
<div id="{{$seat->id}}" class="col-2 seats ">
<img src="{{asset('assets/img/seats/seat1.png')}}" alt="" style="height:50px;width:50px">
</div>
{{-- @endfor --}}
</div>
{{-- @endwhile --}}
{{$newrow=$seat->seat_row}}
@endforeach
Advertisement
Answer
you need to compare it with the previous seat.
Instead of using @foreach ($allseats as $seat)
you can use @foreach ($allseats as $key => $seat)
and then check in your loop if $seat !== $allseats[$key-1]
I hope that guides you on the correct track.