src/Entity/CategoryEvent.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CategoryEventRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use JMS\Serializer\Annotation\Groups;
  8. use App\Entity\Traits\Timestampable;
  9. #[ORM\Entity(repositoryClassCategoryEventRepository::class)]
  10. #[ORM\HasLifecycleCallbacks]
  11. class CategoryEvent
  12. {
  13.     use Timestampable;
  14.     #[ORM\Id]
  15.     #[ORM\GeneratedValue]
  16.     #[ORM\Column]
  17.     #[Groups(['getEvent'])]
  18.     private ?int $id null;
  19.     #[ORM\Column(length255)]
  20.     #[Groups(['getEvent'])]
  21.     private ?string $name null;
  22.     #[ORM\OneToMany(mappedBy'categoryEvent'targetEntityEvent::class)]
  23.     private Collection $event;
  24.     #[ORM\ManyToOne(inversedBy'categoryEvents'cascade: ["persist"])]
  25.     private ?User $author null;
  26.     #[ORM\ManyToOne(inversedBy'categoryEventsEdited'cascade: ["persist"])]
  27.     private ?User $editor null;
  28.     #[ORM\ManyToOne(inversedBy'categoryEvents'cascade: ["persist"])]
  29.     #[ORM\JoinColumn(nullablefalse)]
  30.     private ?School $school null;
  31.     public function __construct()
  32.     {
  33.         $this->event = new ArrayCollection();
  34.     }
  35.     public function __toString():string
  36.     {
  37.         return $this->name;
  38.     }
  39.     public function getId(): ?int
  40.     {
  41.         return $this->id;
  42.     }
  43.     public function getName(): ?string
  44.     {
  45.         return $this->name;
  46.     }
  47.     public function setName(string $name): static
  48.     {
  49.         $this->name $name;
  50.         return $this;
  51.     }
  52.     /**
  53.      * @return Collection<int, Event>
  54.      */
  55.     public function getEvent(): Collection
  56.     {
  57.         return $this->event;
  58.     }
  59.     public function addEvent(Event $event): static
  60.     {
  61.         if (!$this->event->contains($event)) {
  62.             $this->event->add($event);
  63.             $event->setCategoryEvent($this);
  64.         }
  65.         return $this;
  66.     }
  67.     public function removeEvent(Event $event): static
  68.     {
  69.         if ($this->event->removeElement($event)) {
  70.             // set the owning side to null (unless already changed)
  71.             if ($event->getCategoryEvent() === $this) {
  72.                 $event->setCategoryEvent(null);
  73.             }
  74.         }
  75.         return $this;
  76.     }
  77.     public function getAuthor(): ?User
  78.     {
  79.         return $this->author;
  80.     }
  81.     public function setAuthor(?User $author): static
  82.     {
  83.         $this->author $author;
  84.         return $this;
  85.     }
  86.     public function getEditor(): ?User
  87.     {
  88.         return $this->editor;
  89.     }
  90.     public function setEditor(?User $editor): static
  91.     {
  92.         $this->editor $editor;
  93.         return $this;
  94.     }
  95.     public function getSchool(): ?School
  96.     {
  97.         return $this->school;
  98.     }
  99.     public function setSchool(?School $school): static
  100.     {
  101.         $this->school $school;
  102.         return $this;
  103.     }
  104. }