src/Entity/Gos/EventFormula.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Gos;
  3. use App\Repository\Gos\EventFormulaRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity(repositoryClass=EventFormulaRepository::class)
  9.  * @ORM\HasLifecycleCallbacks
  10.  */
  11. class EventFormula
  12. {
  13.     /**
  14.      * @ORM\Id
  15.      * @ORM\GeneratedValue
  16.      * @ORM\Column(type="integer")
  17.      */
  18.     private $id;
  19.     /**
  20.      * @ORM\Column(type="string", length=255)
  21.      */
  22.     private $name;
  23.     /**
  24.      * @ORM\Column(type="datetime")
  25.      */
  26.     private $createdAt;
  27.     /**
  28.      * @ORM\Column(type="datetime", nullable=true)
  29.      */
  30.     private $updatedAt;
  31.     /**
  32.      * @ORM\OneToMany(targetEntity=Events::class, mappedBy="eventFormula")
  33.      */
  34.     private $events;
  35.     public function __construct()
  36.     {
  37.         $this->events = new ArrayCollection();
  38.     }
  39.     /** @ORM\PrePersist() */
  40.     public function prePersist()
  41.     {
  42.         $this->createdAt = new \DateTime();
  43.     }
  44.     /** @ORM\PreUpdate() */
  45.     public function preUpdate()
  46.     {
  47.         $this->updatedAt = new \DateTime();
  48.     }
  49.     public function __toString()
  50.     {
  51.         return (string)$this->name;
  52.     }
  53.     public function getId(): ?int
  54.     {
  55.         return $this->id;
  56.     }
  57.     public function getName(): ?string
  58.     {
  59.         return $this->name;
  60.     }
  61.     public function setName(string $name): self
  62.     {
  63.         $this->name $name;
  64.         return $this;
  65.     }
  66.     public function getCreatedAt(): ?\DateTimeInterface
  67.     {
  68.         return $this->createdAt;
  69.     }
  70.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  71.     {
  72.         $this->createdAt $createdAt;
  73.         return $this;
  74.     }
  75.     public function getUpdatedAt(): ?\DateTimeInterface
  76.     {
  77.         return $this->updatedAt;
  78.     }
  79.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
  80.     {
  81.         $this->updatedAt $updatedAt;
  82.         return $this;
  83.     }
  84.     /**
  85.      * @return Collection|Events[]
  86.      */
  87.     public function getEvents(): Collection
  88.     {
  89.         return $this->events;
  90.     }
  91.     public function addEvent(Events $event): self
  92.     {
  93.         if (!$this->events->contains($event)) {
  94.             $this->events[] = $event;
  95.             $event->setEventFormula($this);
  96.         }
  97.         return $this;
  98.     }
  99.     public function removeEvent(Events $event): self
  100.     {
  101.         if ($this->events->contains($event)) {
  102.             $this->events->removeElement($event);
  103.             // set the owning side to null (unless already changed)
  104.             if ($event->getEventFormula() === $this) {
  105.                 $event->setEventFormula(null);
  106.             }
  107.         }
  108.         return $this;
  109.     }
  110. }