Skip to content
Advertisement

add rows and columns base on condition in laravel blade

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

@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.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement