jeudi 30 novembre 2017

Laravel 5.4 printing out a seating plan

I have an sql table of seats with the columns (id,row, seat_number). Im trying to print out the seats something like this,

A 1,2,3
B 4,5,6
C 7,8,9

I've managed to do this by hard coding if statements for each row, like so

    @if($row->rw==='A')
                  <div class="row">
                      <div class="col-md-1"></div>
                     @foreach($seats as $seat)
                         @if($seat->rw === 'A')
                             
                        @endif
                @endforeach
            </div>
        @endif

What I would like to know is a better method that doesn't require me to hard code each row. I'm guessing it would be some loop that would go through and check the row for unique character and print the seat_numbers in that row.

I'm fairly new to laravel and php as I'm sure you can tell, I don't want anyone to do the work for me I just want pointing in the right direction. Any help is greatly appreciated.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire