src/Entity/SageSubFamily.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\SageSubFamilyRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity(repositoryClass=SageSubFamilyRepository::class)
  9.  * @ORM\HasLifecycleCallbacks()
  10.  */
  11. class SageSubFamily
  12. {
  13.     /**
  14.      * @ORM\Id
  15.      * @ORM\GeneratedValue
  16.      * @ORM\Column(type="integer")
  17.      */
  18.     private $id;
  19.     /**
  20.      * @ORM\Column(type="string", length=20)
  21.      */
  22.     private $sageCode;
  23.     /**
  24.      * @ORM\Column(type="string", length=255)
  25.      */
  26.     private $name;
  27.     /**
  28.      * @ORM\ManyToOne(targetEntity=SageFamily::class, inversedBy="sageSubFamilies")
  29.      * @ORM\JoinColumn(nullable=false)
  30.      */
  31.     private $family;
  32.     /**
  33.      * @ORM\Column(type="datetime", nullable=true)
  34.      */
  35.     private $syncDate;
  36.     /**
  37.      * @ORM\Column(type="datetime_immutable")
  38.      */
  39.     private $createdAt;
  40.     /**
  41.      * @ORM\Column(type="datetime_immutable")
  42.      */
  43.     private $updatedAt;
  44.     /**
  45.      * @ORM\OneToMany(targetEntity=SageArticle::class, mappedBy="subfamily")
  46.      */
  47.     private $sageArticles;
  48.     public function __construct()
  49.     {
  50.         $this->sageArticles = new ArrayCollection();
  51.     }
  52.     public function getId(): ?int
  53.     {
  54.         return $this->id;
  55.     }
  56.     public function getSageCode(): ?string
  57.     {
  58.         return $this->sageCode;
  59.     }
  60.     public function setSageCode(string $sageCode): self
  61.     {
  62.         $this->sageCode $sageCode;
  63.         return $this;
  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 getFamily(): ?SageFamily
  75.     {
  76.         return $this->family;
  77.     }
  78.     public function setFamily(?SageFamily $family): self
  79.     {
  80.         $this->family $family;
  81.         return $this;
  82.     }
  83.     public function getSyncDate(): ?\DateTimeInterface
  84.     {
  85.         return $this->syncDate;
  86.     }
  87.     public function setSyncDate(?\DateTimeInterface $syncDate): self
  88.     {
  89.         $this->syncDate $syncDate;
  90.         return $this;
  91.     }
  92.     public function getCreatedAt(): ?\DateTimeImmutable
  93.     {
  94.         return $this->createdAt;
  95.     }
  96.     public function setCreatedAt(\DateTimeImmutable $createdAt): self
  97.     {
  98.         $this->createdAt $createdAt;
  99.         return $this;
  100.     }
  101.     public function getUpdatedAt(): ?\DateTimeImmutable
  102.     {
  103.         return $this->updatedAt;
  104.     }
  105.     public function setUpdatedAt(\DateTimeImmutable $updatedAt): self
  106.     {
  107.         $this->updatedAt $updatedAt;
  108.         return $this;
  109.     }
  110.     /**
  111.      * @return Collection<int, SageArticle>
  112.      */
  113.     public function getSageArticles(): Collection
  114.     {
  115.         return $this->sageArticles;
  116.     }
  117.     public function addSageArticle(SageArticle $sageArticle): self
  118.     {
  119.         if (!$this->sageArticles->contains($sageArticle)) {
  120.             $this->sageArticles[] = $sageArticle;
  121.             $sageArticle->setSubfamily($this);
  122.         }
  123.         return $this;
  124.     }
  125.     public function removeSageArticle(SageArticle $sageArticle): self
  126.     {
  127.         if ($this->sageArticles->removeElement($sageArticle)) {
  128.             // set the owning side to null (unless already changed)
  129.             if ($sageArticle->getSubfamily() === $this) {
  130.                 $sageArticle->setSubfamily(null);
  131.             }
  132.         }
  133.         return $this;
  134.     }
  135.     /**
  136.      * @ORM\PrePersist
  137.      */
  138.     public function prePersist(): void
  139.     {
  140.         $this->createdAt = new \DateTimeImmutable();
  141.         $this->updatedAt = new \DateTimeImmutable();
  142.     }
  143.     /**
  144.      * @ORM\PreUpdate
  145.      */
  146.     public function preUpdate(): void
  147.     {
  148.         $this->updatedAt = new \DateTimeImmutable();
  149.     }
  150. }