Forráskód Böngészése

add missing relations to entities

Olivier Massot 5 hónapja
szülő
commit
807891c3da

+ 34 - 0
src/Entity/Booking/Course.php

@@ -88,6 +88,10 @@ class Course extends AbstractBooking
     #[ORM\OneToMany(targetEntity: EducationStudentWish::class, mappedBy: 'course', cascade: [])]
     protected Collection $educationStudentWishes;
 
+    /** @var Collection<int, Presence> */
+    #[ORM\OneToMany(targetEntity: Presence::class, mappedBy: 'course', cascade: ['persist', 'remove'])]
+    protected Collection $presences;
+
     public function __construct()
     {
         $this->eventRecur = new ArrayCollection();
@@ -99,6 +103,7 @@ class Course extends AbstractBooking
         $this->equipments = new ArrayCollection();
         $this->attendanceBooking = new ArrayCollection();
         $this->educationStudentWishes = new ArrayCollection();
+        $this->presences = new ArrayCollection();
         parent::__construct();
     }
 
@@ -347,6 +352,35 @@ class Course extends AbstractBooking
     public function removeEducationStudentWish(EducationStudentWish $educationStudentWish): self
     {
         $this->educationStudentWishes->removeElement($educationStudentWish);
+        return $this;
+    }
+
+    /**
+     * @return Collection<int, Presence>
+     */
+    public function getPresences(): Collection
+    {
+        return $this->presences;
+    }
+
+    public function addPresence(Presence $presence): self
+    {
+        if (!$this->presences->contains($presence)) {
+            $this->presences[] = $presence;
+            $presence->setCourse($this);
+        }
+
+        return $this;
+    }
+
+    public function removePresence(Presence $presence): self
+    {
+        if ($this->presences->removeElement($presence)) {
+            // set the owning side to null (unless already changed)
+            if ($presence->getCourse() === $this) {
+                $presence->setCourse(null);
+            }
+        }
 
         return $this;
     }

+ 34 - 0
src/Entity/Booking/EducationalProject.php

@@ -92,6 +92,10 @@ class EducationalProject extends AbstractBooking
     #[ORM\OneToOne(targetEntity: EducationalProjectAge::class, cascade: ['persist'])]
     protected ?EducationalProjectAge $ageDistribution;
 
+    /** @var Collection<int, Presence> */
+    #[ORM\OneToMany(targetEntity: Presence::class, mappedBy: 'educationalProject', cascade: ['persist', 'remove'])]
+    protected Collection $presences;
+
     public function __construct()
     {
         $this->eventRecur = new ArrayCollection();
@@ -104,6 +108,7 @@ class EducationalProject extends AbstractBooking
         $this->attendanceBooking = new ArrayCollection();
         $this->organizer = new ArrayCollection();
         $this->equipments = new ArrayCollection();
+        $this->presences = new ArrayCollection();
         parent::__construct();
     }
 
@@ -451,6 +456,35 @@ class EducationalProject extends AbstractBooking
     public function setAgeDistribution(?EducationalProjectAge $ageDistribution): self
     {
         $this->ageDistribution = $ageDistribution;
+        return $this;
+    }
+
+    /**
+     * @return Collection<int, Presence>
+     */
+    public function getPresences(): Collection
+    {
+        return $this->presences;
+    }
+
+    public function addPresence(Presence $presence): self
+    {
+        if (!$this->presences->contains($presence)) {
+            $this->presences[] = $presence;
+            $presence->setEducationalProject($this);
+        }
+
+        return $this;
+    }
+
+    public function removePresence(Presence $presence): self
+    {
+        if ($this->presences->removeElement($presence)) {
+            // set the owning side to null (unless already changed)
+            if ($presence->getEducationalProject() === $this) {
+                $presence->setEducationalProject(null);
+            }
+        }
 
         return $this;
     }

+ 34 - 0
src/Entity/Booking/Event.php

@@ -117,6 +117,10 @@ class Event extends AbstractBooking
     #[Assert\Positive]
     protected ?float $priceMaxi = null;
 
+    /** @var Collection<int, Presence> */
+    #[ORM\OneToMany(targetEntity: Presence::class, mappedBy: 'event', cascade: ['persist', 'remove'])]
+    protected Collection $presences;
+
     public function __construct()
     {
         $this->eventRecur = new ArrayCollection();
@@ -128,6 +132,7 @@ class Event extends AbstractBooking
         $this->attendanceBooking = new ArrayCollection();
         $this->organizer = new ArrayCollection();
         $this->equipments = new ArrayCollection();
+        $this->presences = new ArrayCollection();
         parent::__construct();
     }
 
@@ -417,6 +422,35 @@ class Event extends AbstractBooking
                 $attendanceBooking->setEvent(null);
             }
         }
+        return $this;
+    }
+
+    /**
+     * @return Collection<int, Presence>
+     */
+    public function getPresences(): Collection
+    {
+        return $this->presences;
+    }
+
+    public function addPresence(Presence $presence): self
+    {
+        if (!$this->presences->contains($presence)) {
+            $this->presences[] = $presence;
+            $presence->setEvent($this);
+        }
+
+        return $this;
+    }
+
+    public function removePresence(Presence $presence): self
+    {
+        if ($this->presences->removeElement($presence)) {
+            // set the owning side to null (unless already changed)
+            if ($presence->getEvent() === $this) {
+                $presence->setEvent(null);
+            }
+        }
 
         return $this;
     }

+ 34 - 0
src/Entity/Booking/Examen.php

@@ -64,6 +64,10 @@ class Examen extends AbstractBooking
     #[ORM\OneToMany(targetEntity: AttendanceBooking::class, mappedBy: 'examen', cascade: ['persist', 'remove'])]
     protected Collection $attendanceBooking;
 
+    /** @var Collection<int, Presence> */
+    #[ORM\OneToMany(targetEntity: Presence::class, mappedBy: 'examen', cascade: ['persist', 'remove'])]
+    protected Collection $presences;
+
     #[ORM\ManyToOne(inversedBy: 'examens')]
     #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
     protected ?Place $place;
@@ -78,6 +82,7 @@ class Examen extends AbstractBooking
         $this->educationCurriculum = new ArrayCollection();
         $this->convocation = new ArrayCollection();
         $this->attendanceBooking = new ArrayCollection();
+        $this->presences = new ArrayCollection();
         parent::__construct();
     }
 
@@ -341,6 +346,35 @@ class Examen extends AbstractBooking
     public function removeTag(Tagg $tag): self
     {
         $this->tags->removeElement($tag);
+        return $this;
+    }
+
+    /**
+     * @return Collection<int, Presence>
+     */
+    public function getPresences(): Collection
+    {
+        return $this->presences;
+    }
+
+    public function addPresence(Presence $presence): self
+    {
+        if (!$this->presences->contains($presence)) {
+            $this->presences[] = $presence;
+            $presence->setExamen($this);
+        }
+
+        return $this;
+    }
+
+    public function removePresence(Presence $presence): self
+    {
+        if ($this->presences->removeElement($presence)) {
+            // set the owning side to null (unless already changed)
+            if ($presence->getExamen() === $this) {
+                $presence->setExamen(null);
+            }
+        }
 
         return $this;
     }

+ 116 - 0
src/Entity/Booking/Presence.php

@@ -0,0 +1,116 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Entity\Booking;
+
+use App\Entity\Traits\CreatedOnAndByTrait;
+use Doctrine\ORM\Mapping as ORM;
+use Symfony\Component\Validator\Constraints as Assert;
+
+#[ORM\Entity]
+class Presence
+{
+    use CreatedOnAndByTrait;
+
+    #[ORM\Column(type: 'integer')]
+    #[ORM\Id]
+    #[ORM\GeneratedValue(strategy: 'AUTO')]
+    private ?int $id = null;
+
+    #[ORM\Column(type: 'json', nullable: true)]
+    private ?array $accessesId = null;
+
+    #[ORM\ManyToOne(targetEntity: Course::class, inversedBy: 'presences')]
+    private ?Course $course = null;
+
+    #[ORM\ManyToOne(targetEntity: EducationalProject::class, inversedBy: 'presences')]
+    private ?EducationalProject $educationalProject = null;
+
+    #[ORM\ManyToOne(targetEntity: Event::class, inversedBy: 'presences')]
+    private ?Event $event = null;
+
+    #[ORM\ManyToOne(targetEntity: Examen::class, inversedBy: 'presences')]
+    private ?Examen $examen = null;
+
+    #[ORM\Column(type: 'datetime', nullable: true)]
+    #[Assert\DateTime]
+    private ?\DateTimeInterface $datetimeStart = null;
+
+    public function getId(): ?int
+    {
+        return $this->id;
+    }
+
+    public function getAccessesId(): ?array
+    {
+        return $this->accessesId;
+    }
+
+    public function setAccessesId(?array $accessesId): self
+    {
+        $this->accessesId = $accessesId;
+
+        return $this;
+    }
+
+    public function getCourse(): ?Course
+    {
+        return $this->course;
+    }
+
+    public function setCourse(?Course $course): self
+    {
+        $this->course = $course;
+
+        return $this;
+    }
+
+    public function getEducationalProject(): ?EducationalProject
+    {
+        return $this->educationalProject;
+    }
+
+    public function setEducationalProject(?EducationalProject $educationalProject): self
+    {
+        $this->educationalProject = $educationalProject;
+
+        return $this;
+    }
+
+    public function getEvent(): ?Event
+    {
+        return $this->event;
+    }
+
+    public function setEvent(?Event $event): self
+    {
+        $this->event = $event;
+
+        return $this;
+    }
+
+    public function getExamen(): ?Examen
+    {
+        return $this->examen;
+    }
+
+    public function setExamen(?Examen $examen): self
+    {
+        $this->examen = $examen;
+
+        return $this;
+    }
+
+    public function getDatetimeStart(): ?\DateTimeInterface
+    {
+        return $this->datetimeStart;
+    }
+
+    public function setDatetimeStart(?\DateTimeInterface $datetimeStart): self
+    {
+        $this->datetimeStart = $datetimeStart;
+
+        return $this;
+    }
+}