Previously I wanted to get time slots between $starttime and $endtime, divided by $duration value.
We managed to get it working with this code :
$starttime = '9:00'; // your start time
$endtime = '21:00'; // End time
$duration = '30'; // split by 30 mins
$array_of_time = array ();
$start_time = strtotime ($starttime); //change to strtotime
$end_time = strtotime ($endtime); //change to strtotime
$add_mins = $duration * 60;
while ($start_time <= $end_time) // loop between time
{
$array_of_time[] = date ("h:i", $start_time);
$start_time += $add_mins; // to check endtie=me
}
$new_array_of_time = array ();
for($i = 0; $i < count($array_of_time) - 1; $i++)
{
$new_array_of_time[] = '' . $array_of_time[$i] . ' - ' . $array_of_time[$i + 1];
}
Now the issue is I don't want to show the timeslots that match dates in my appointments table.
To get the Appointments matching that date , i did :
$appointments = Appointment::where('user_id', $user->id)->where('appointment_datetime', $date->toDateString() )->get();
Now this returns me all appointments, ... in each appointment we have a column appointment_start and appointment_end , witch are formated in TIME .
Next step would be to check all appointment for matching timeslots ... and this is where I am stuck. Thank you for your help.