src/Entity/Species.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\SpeciesRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassSpeciesRepository::class)]
  8. class Species
  9. {
  10.     #[ORM\Id]
  11.     #[ORM\GeneratedValue]
  12.     #[ORM\Column(type'integer')]
  13.     private $id;
  14.     #[ORM\Column(type'string'length255nullabletrue)]
  15.     private $name;
  16.     #[ORM\Column(type'datetime')]
  17.     private $modified;
  18.     #[ORM\Column(type'datetime')]
  19.     private $created;
  20.     #[ORM\OneToMany(targetEntityProductsSpecies::class, mappedBy'species')]
  21.     private $productsSpecies;
  22.     #[ORM\Column(type'string'length255)]
  23.     private $icon;
  24.     public function __construct()
  25.     {
  26.         $this->setCreated(new \DateTime());
  27.         if ($this->getModified() == null) {
  28.             $this->setModified(new \DateTime());
  29.         }
  30.         $this->productsSpecies = new ArrayCollection();
  31.     }
  32.     public function getId(): ?int
  33.     {
  34.         return $this->id;
  35.     }
  36.     public function getName(): ?string
  37.     {
  38.         return $this->name;
  39.     }
  40.     public function setName(string $name): self
  41.     {
  42.         $this->name $name;
  43.         return $this;
  44.     }
  45.     public function getModified(): ?\DateTimeInterface
  46.     {
  47.         return $this->modified;
  48.     }
  49.     public function setModified(\DateTimeInterface $modified): self
  50.     {
  51.         $this->modified $modified;
  52.         return $this;
  53.     }
  54.     public function getCreated(): ?\DateTimeInterface
  55.     {
  56.         return $this->created;
  57.     }
  58.     public function setCreated(\DateTimeInterface $created): self
  59.     {
  60.         $this->created $created;
  61.         return $this;
  62.     }
  63.     /**
  64.      * @return Collection|Products[]
  65.      */
  66.     public function getProducts(): Collection
  67.     {
  68.         return $this->products;
  69.     }
  70.     public function addProducts(Products $products): self
  71.     {
  72.         if (!$this->products->contains($products)) {
  73.             $this->products[] = $products;
  74.         }
  75.         return $this;
  76.     }
  77.     public function removeProducts(Products $products): self
  78.     {
  79.         $this->products->removeElement($products);
  80.         return $this;
  81.     }
  82.     /**
  83.      * @return string
  84.      */
  85.     public function __toString(){
  86.         return $this->getName();
  87.     }
  88.     /**
  89.      * @return Collection<int, ProductsSpecies>
  90.      */
  91.     public function getProductsSpecies(): Collection
  92.     {
  93.         return $this->productsSpecies;
  94.     }
  95.     public function addProductsSpecies(ProductsSpecies $productsSpecies): self
  96.     {
  97.         if (!$this->productsSpecies->contains($productsSpecies)) {
  98.             $this->productsSpecies[] = $productsSpecies;
  99.             $productsSpecies->setSpecies($this);
  100.         }
  101.         return $this;
  102.     }
  103.     public function removeProductsSpecies(ProductsSpecies $productsSpecies): self
  104.     {
  105.         if ($this->productsSpecies->removeElement($productsSpecies)) {
  106.             // set the owning side to null (unless already changed)
  107.             if ($productsSpecies->getSpecies() === $this) {
  108.                 $productsSpecies->setSpecies(null);
  109.             }
  110.         }
  111.         return $this;
  112.     }
  113.     public function getIcon(): ?string
  114.     {
  115.         return $this->icon;
  116.     }
  117.     public function setIcon(string $icon): self
  118.     {
  119.         $this->icon $icon;
  120.         return $this;
  121.     }
  122. }