src/Entity/TimeSlot.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\TimeSlotRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use \Boab\CmsBundle\Entity\User;
  9. #[ORM\Entity(repositoryClassTimeSlotRepository::class)]
  10. class TimeSlot
  11. {
  12.     #[ORM\Id]
  13.     #[ORM\GeneratedValue]
  14.     #[ORM\Column]
  15.     private ?int $id null;
  16.     #[ORM\Column(nullabletrue)]
  17.     private ?\DateTimeImmutable $updatedAt null;
  18.     #[ORM\Column]
  19.     private ?\DateTimeImmutable $createdAt null;
  20.     #[ORM\ManyToOne(inversedBy'timeSlots')]
  21.     private ?User $createdBy null;
  22.     #[ORM\Column(length10)]
  23.     private ?string $day null;
  24.     #[ORM\Column(typeTypes::TIME_MUTABLE)]
  25.     private ?\DateTimeInterface $startTime null;
  26.     #[ORM\Column(typeTypes::TIME_MUTABLE)]
  27.     private ?\DateTimeInterface $endTime null;
  28.     #[ORM\OneToMany(mappedBy'timeSlot'targetEntityAppointment::class)]
  29.     private Collection $appointments;
  30.     public function __construct()
  31.     {
  32.         $this->appointments = new ArrayCollection();
  33.     }
  34.     public function getId(): ?int
  35.     {
  36.         return $this->id;
  37.     }
  38.     public function getCreatedAt(): ?\DateTimeImmutable
  39.     {
  40.         return $this->createdAt;
  41.     }
  42.     public function setCreatedAt(\DateTimeImmutable $createdAt): static
  43.     {
  44.         $this->createdAt $createdAt;
  45.         return $this;
  46.     }
  47.     public function getCreatedBy(): ?User
  48.     {
  49.         return $this->createdBy;
  50.     }
  51.     public function setCreatedBy(?User $createdBy): static
  52.     {
  53.         $this->createdBy $createdBy;
  54.         return $this;
  55.     }
  56.     public function getDay(): ?string
  57.     {
  58.         return $this->day;
  59.     }
  60.     public function setDay(string $day): static
  61.     {
  62.         $this->day $day;
  63.         return $this;
  64.     }
  65.     public function getStartTime(): ?\DateTimeInterface
  66.     {
  67.         return $this->startTime;
  68.     }
  69.     public function setStartTime(\DateTimeInterface $startTime): static
  70.     {
  71.         $this->startTime $startTime;
  72.         return $this;
  73.     }
  74.     public function getEndTime(): ?\DateTimeInterface
  75.     {
  76.         return $this->endTime;
  77.     }
  78.     public function setEndTime(\DateTimeInterface $endTime): static
  79.     {
  80.         $this->endTime $endTime;
  81.         return $this;
  82.     }
  83.     /**
  84.      * @return Collection<int, Appointment>
  85.      */
  86.     public function getAppointments(): Collection
  87.     {
  88.         return $this->appointments;
  89.     }
  90.     public function addAppointment(Appointment $appointment): static
  91.     {
  92.         if (!$this->appointments->contains($appointment)) {
  93.             $this->appointments->add($appointment);
  94.             $appointment->setTimeSlot($this);
  95.         }
  96.         return $this;
  97.     }
  98.     public function removeAppointment(Appointment $appointment): static
  99.     {
  100.         if ($this->appointments->removeElement($appointment)) {
  101.             // set the owning side to null (unless already changed)
  102.             if ($appointment->getTimeSlot() === $this) {
  103.                 $appointment->setTimeSlot(null);
  104.             }
  105.         }
  106.         return $this;
  107.     }
  108.     public function getDescription()
  109.     {
  110.         return sprintf('%s - %s'$this->getStartTime()->format('h.i A'), $this->getEndTime()->format('h.i A'));
  111.     }
  112. }