This is a kind of twit togue, but I try to explain as good as I can.
I have a loop inside a loop as you could see here:
@for($i = 8; $i <= 17; $i++) // These are the hours. From 8:00 hour to 17:00 hour (German hour format) @foreach($employee->appointments as $appointment) // I take the appointment of each employee @if( $appointment->date->translatedFormat('D j M') != today()->translatedFormat('D j M')) @continue //if the appointment is not from today, continue @else @if( $appointment->date->format('H') != $i ) <h3> <a href="link_to_create_appointment_form">Add an appointment</a></h3> // insert a link to create a new apppointment @else // insert the Appointment @endif @endif @endforeach @endfor
My problem is as follow:
After the first appointment is inserted (Appointment == today && now()), the foreach goes to next appointment, but start from the beginning.
At the end if I have an appointment at 9:00 and another at 10:00 I get the following:
8:00 - add an appointment 9:00 - APPOINTMENT 1 8:00 - add an appointment // <---- the ouside loop started from the beginning of the day 9:00 - add an appointment 10:00 - APPOINTMENT 2
You could see an image in the following link: http://severus.es/wp-content/uploads/2019/11/termin-plan.png
The question is: