src/Services/CountBookingSlots.php line 45

Open in your IDE?
  1. <?php
  2. namespace App\Services;
  3. use App\Repository\OfficeAppointmentsRepository;
  4. class CountBookingSlots
  5. {
  6.     public function bookingSlots(\DateTimeInterface $dateint $time)
  7.     {
  8.         $all_booking_slots $this->officeAppointmentsRepository->findAll();
  9.         $booking_slots = [];
  10.         foreach ($all_booking_slots as $booking_slot) {
  11.             if ($booking_slot->getDate() == $date and $booking_slot->getTime() == $time and $booking_slot->getClient() == null) {
  12.                 $booking_slots[] = $booking_slot;
  13.             }
  14.         }
  15.         if ($booking_slots) {
  16.             return count($booking_slots);
  17.         } else {
  18.             return count($booking_slots);
  19.         }
  20.     }
  21.     public function findBookingId(\DateTimeInterface $dateint $time)
  22.     {
  23.         $all_booking_slots $this->officeAppointmentsRepository->findAll();
  24.         foreach ($all_booking_slots as $booking_slot) {
  25.             if ($booking_slot->getDate() == $date and $booking_slot->getTime() == $time and $booking_slot->getClient() == null) {
  26.                 return $booking_slot->getId();
  27.             }
  28.         }
  29.        return null;
  30.     }
  31.     public function __construct(OfficeAppointmentsRepository $officeAppointmentsRepository)
  32.     {
  33.         $this->officeAppointmentsRepository $officeAppointmentsRepository;
  34.     }
  35. }