<?phpnamespace App\Entity\Gos;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;/** * @ORM\Entity(repositoryClass="App\Repository\EventTypeRepository") * @ORM\HasLifecycleCallbacks */class EventType{ /** * @ORM\Id() * @ORM\GeneratedValue() * @ORM\Column(type="integer") */ private $id; /** * @ORM\Column(type="string") */ private $name; /** * @ORM\Column(type="boolean", nullable=true) */ private $isActive; /** * @ORM\OneToMany(targetEntity="Product", mappedBy="eventType") */ private $products; /** * @ORM\Column(type="datetime") */ private $createdAt; /** * @ORM\Column(type="datetime", nullable=true) */ private $updatedAt; /** * @ORM\OneToMany(targetEntity=Events::class, mappedBy="eventType") */ private $events; public function __construct() { $this->products = new ArrayCollection(); $this->events = new ArrayCollection(); } /** @ORM\PrePersist() */ public function prePersist() { $this->createdAt = new \DateTime(); } /** @ORM\PreUpdate() */ public function preUpdate() { $this->updatedAt = new \DateTime(); } public function __toString() { return (string)$this->name; } public function getId(): ?int { return $this->id; } public function getName(): ?string { return $this->name; } public function setName(string $name): self { $this->name = $name; return $this; } public function getIsActive(): ?bool { return $this->isActive; } public function setIsActive(?bool $isActive): self { $this->isActive = $isActive; return $this; } public function getCreatedAt(): ?\DateTimeInterface { return $this->createdAt; } public function setCreatedAt(\DateTimeInterface $createdAt): self { $this->createdAt = $createdAt; return $this; } public function getUpdatedAt(): ?\DateTimeInterface { return $this->updatedAt; } public function setUpdatedAt(?\DateTimeInterface $updatedAt): self { $this->updatedAt = $updatedAt; return $this; } /** * @return Collection|Product[] */ public function getProducts(): Collection { return $this->products; } public function addProduct(Product $product): self { if (!$this->products->contains($product)) { $this->products[] = $product; $product->setEventType($this); } return $this; } public function removeProduct(Product $product): self { if ($this->products->contains($product)) { $this->products->removeElement($product); // set the owning side to null (unless already changed) if ($product->getEventType() === $this) { $product->setEventType(null); } } return $this; } /* ****************************** GETTERS & SETTERS ****************************** */ /** * @return Collection|Events[] */ public function getEvents(): Collection { return $this->events; } public function addEvent(Events $event): self { if (!$this->events->contains($event)) { $this->events[] = $event; $event->setEventType($this); } return $this; } public function removeEvent(Events $event): self { if ($this->events->contains($event)) { $this->events->removeElement($event); // set the owning side to null (unless already changed) if ($event->getEventType() === $this) { $event->setEventType(null); } } return $this; }}