src/Entity/Gos/EventType.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Gos;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. /**
  7.  * @ORM\Entity(repositoryClass="App\Repository\EventTypeRepository")
  8.  * @ORM\HasLifecycleCallbacks
  9.  */
  10. class EventType
  11. {
  12.     /**
  13.      * @ORM\Id()
  14.      * @ORM\GeneratedValue()
  15.      * @ORM\Column(type="integer")
  16.      */
  17.     private $id;
  18.     /**
  19.      * @ORM\Column(type="string")
  20.      */
  21.     private $name;
  22.     /**
  23.      * @ORM\Column(type="boolean", nullable=true)
  24.      */
  25.     private $isActive;
  26.     /**
  27.      * @ORM\OneToMany(targetEntity="Product", mappedBy="eventType")
  28.      */
  29.     private $products;
  30.     /**
  31.      * @ORM\Column(type="datetime")
  32.      */
  33.     private $createdAt;
  34.     /**
  35.      * @ORM\Column(type="datetime", nullable=true)
  36.      */
  37.     private $updatedAt;
  38.     /**
  39.      * @ORM\OneToMany(targetEntity=Events::class, mappedBy="eventType")
  40.      */
  41.     private $events;
  42.     public function __construct()
  43.     {
  44.         $this->products = new ArrayCollection();
  45.         $this->events = new ArrayCollection();
  46.     }
  47.     /** @ORM\PrePersist() */
  48.     public function prePersist()
  49.     {
  50.         $this->createdAt = new \DateTime();
  51.     }
  52.     /** @ORM\PreUpdate() */
  53.     public function preUpdate()
  54.     {
  55.         $this->updatedAt = new \DateTime();
  56.     }
  57.     public function __toString()
  58.     {
  59.         return (string)$this->name;
  60.     }
  61.     public function getId(): ?int
  62.     {
  63.         return $this->id;
  64.     }
  65.     public function getName(): ?string
  66.     {
  67.         return $this->name;
  68.     }
  69.     public function setName(string $name): self
  70.     {
  71.         $this->name $name;
  72.         return $this;
  73.     }
  74.     public function getIsActive(): ?bool
  75.     {
  76.         return $this->isActive;
  77.     }
  78.     public function setIsActive(?bool $isActive): self
  79.     {
  80.         $this->isActive $isActive;
  81.         return $this;
  82.     }
  83.     public function getCreatedAt(): ?\DateTimeInterface
  84.     {
  85.         return $this->createdAt;
  86.     }
  87.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  88.     {
  89.         $this->createdAt $createdAt;
  90.         return $this;
  91.     }
  92.     public function getUpdatedAt(): ?\DateTimeInterface
  93.     {
  94.         return $this->updatedAt;
  95.     }
  96.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
  97.     {
  98.         $this->updatedAt $updatedAt;
  99.         return $this;
  100.     }
  101.     /**
  102.      * @return Collection|Product[]
  103.      */
  104.     public function getProducts(): Collection
  105.     {
  106.         return $this->products;
  107.     }
  108.     public function addProduct(Product $product): self
  109.     {
  110.         if (!$this->products->contains($product)) {
  111.             $this->products[] = $product;
  112.             $product->setEventType($this);
  113.         }
  114.         return $this;
  115.     }
  116.     public function removeProduct(Product $product): self
  117.     {
  118.         if ($this->products->contains($product)) {
  119.             $this->products->removeElement($product);
  120.             // set the owning side to null (unless already changed)
  121.             if ($product->getEventType() === $this) {
  122.                 $product->setEventType(null);
  123.             }
  124.         }
  125.         return $this;
  126.     }
  127.     /* ****************************** GETTERS & SETTERS ******************************  */
  128.     /**
  129.      * @return Collection|Events[]
  130.      */
  131.     public function getEvents(): Collection
  132.     {
  133.         return $this->events;
  134.     }
  135.     public function addEvent(Events $event): self
  136.     {
  137.         if (!$this->events->contains($event)) {
  138.             $this->events[] = $event;
  139.             $event->setEventType($this);
  140.         }
  141.         return $this;
  142.     }
  143.     public function removeEvent(Events $event): self
  144.     {
  145.         if ($this->events->contains($event)) {
  146.             $this->events->removeElement($event);
  147.             // set the owning side to null (unless already changed)
  148.             if ($event->getEventType() === $this) {
  149.                 $event->setEventType(null);
  150.             }
  151.         }
  152.         return $this;
  153.     }
  154. }