Wednesday, March 15, 2017

Laravel time table

I am making a time table in Laravel where user can select one field at say 10:00, and reserve equipment until say 12:00.

I have trouble displaying the range from when to when the equipment is reserved

@while($scheduler_start_time < $scheduler_end_time)
    <tr>
        <td></td>
        @foreach($equipment as $instrument)
            <td>
                <a href="#">

                    @if($instrument->reservations->where('reserved_from','=', $scheduler_start_time)
                    ->where('reserved_to','<=', $scheduler_end_time)->first() != null)

                        HERE

                    @else
                        &nbsp;
                    @endif
                </a>
            </td>
        @endforeach
        <?php $scheduler_start_time->addMinutes(30) ?>
    </tr>
@endwhile

One instrument can have many reservations:

enter image description here

And this is what I get when getting reservation where reserved_from equals time. If I use >= I am fetching both records. I need a way to see that for example: Instrument3 is reserved from 6:30 up to 7:30, and then from 9:30 to 10:00



via Norgul

Advertisement