| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- <?php
- declare(strict_types=1);
- namespace App\Entity\Booking;
- use ApiPlatform\Metadata\ApiResource;
- use App\Entity\Access\Access;
- use App\Entity\Billing\FamilyQuotientBandDetail;
- use App\Entity\Billing\ResidenceArea;
- use App\Entity\Core\Tagg;
- use App\Entity\Organization\Organization;
- // use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
- use App\Entity\Product\Equipment;
- use Doctrine\Common\Collections\ArrayCollection;
- use Doctrine\Common\Collections\Collection;
- use Doctrine\ORM\Mapping as ORM;
- /**
- * @todo : A la suite de la migration, il faut supprimer le nom de la table pour avoir une table OrganizationHoliday, et supprimer l'attribut discr.
- *
- * Périodes de vacances d'une Organization
- */
- #[ApiResource(operations: [])]
- // #[Auditable]
- #[ORM\Entity]
- class OrganizationHoliday extends AbstractBooking
- {
- /** @var Collection<int, OrganizationHolidayRecur> */
- #[ORM\OneToMany(targetEntity: OrganizationHolidayRecur::class, mappedBy: 'event', cascade: ['persist'], orphanRemoval: true)]
- private Collection $eventRecur;
- #[ORM\ManyToOne(inversedBy: 'holidays')]
- #[ORM\JoinColumn(nullable: false)]
- private Organization $organization;
- /** @var Collection<int, Access> */
- #[ORM\ManyToMany(targetEntity: Access::class, inversedBy: 'practicalCourses', cascade: [], orphanRemoval: false)]
- #[ORM\JoinTable(name: 'booking_organizer')]
- #[ORM\JoinColumn(name: 'booking_id')]
- protected Collection $organizer;
- /** @var Collection<int, Equipment> */
- #[ORM\ManyToMany(targetEntity: Equipment::class, cascade: [], orphanRemoval: false)]
- #[ORM\JoinTable(name: 'booking_equipment')]
- #[ORM\JoinColumn(name: 'booking_id')]
- #[ORM\InverseJoinColumn(name: 'equipment_id')]
- protected Collection $equipments;
- /** @var Collection<int, Tagg> */
- #[ORM\ManyToMany(targetEntity: Tagg::class, inversedBy: 'bookings', cascade: ['persist'], orphanRemoval: false)]
- #[ORM\JoinTable(name: 'tag_booking')]
- #[ORM\JoinColumn(name: 'booking_id')]
- #[ORM\InverseJoinColumn(name: 'tag_id')]
- protected Collection $tags;
- public function __construct()
- {
- $this->eventRecur = new ArrayCollection();
- $this->organizer = new ArrayCollection();
- $this->equipments = new ArrayCollection();
- $this->tags = new ArrayCollection();
- }
- /**
- * @return Collection<int, OrganizationHolidayRecur>
- */
- public function getEventRecur(): Collection
- {
- return $this->eventRecur;
- }
- public function addEventRecur(OrganizationHolidayRecur $eventRecur): self
- {
- if (!$this->eventRecur->contains($eventRecur)) {
- $this->eventRecur[] = $eventRecur;
- $eventRecur->setEvent($this);
- }
- return $this;
- }
- public function removeEventRecur(OrganizationHolidayRecur $eventRecur): self
- {
- if ($this->eventRecur->removeElement($eventRecur)) {
- // set the owning side to null (unless already changed)
- if ($eventRecur->getEvent() === $this) {
- $eventRecur->setEvent(null);
- }
- }
- return $this;
- }
- public function getOrganization(): ?Organization
- {
- return $this->organization;
- }
- public function setOrganization(?Organization $organization): self
- {
- $this->organization = $organization;
- return $this;
- }
- function getOrganizer(): Collection
- {
- return $this->organizer;
- }
- function addOrganizer(Access $organizer): self
- {
- if (!$this->organizer->contains($organizer)) {
- $this->organizer[] = $organizer;
- $organizer->addPracticalCourse($this);
- }
- return $this;
- }
- function removeOrganizer(Access $organizer): self
- {
- if ($this->organizer->removeElement($organizer)) {
- $organizer->removePracticalCourse($this);
- }
- return $this;
- }
- function getEquipments(): Collection
- {
- return $this->equipments;
- }
- function addEquipment(Equipment $equipment): self
- {
- if (!$this->equipments->contains($equipment)) {
- $this->equipments[] = $equipment;
- // $equipment->addXXX($this);
- }
- return $this;
- }
- function removeEquipment(Equipment $equipment): self
- {
- if ($this->equipments->removeElement($equipment)) {
- // $equipment->removeXXXX($this);
- }
- return $this;
- }
- function getTags(): Collection
- {
- return $this->tags;
- }
- function addTag(Tagg $tag): self
- {
- if (!$this->tags->contains($tag)) {
- $this->tags[] = $tag;
- $tag->addBooking($this);
- }
- return $this;
- }
- function removeTag(Tagg $tag): self
- {
- if ($this->tags->removeElement($tag)) {
- $tag->removeBooking($this);
- }
- return $this;
- }
- }
|