src/Entity/ProductType.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\traits\base64Field;
  4. use App\Entity\traits\Timestapable;
  5. use App\Repository\ProductTypeRepository;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\DBAL\Types\Types;
  9. use Doctrine\ORM\Mapping as ORM;
  10. #[ORM\Entity(repositoryClassProductTypeRepository::class)]
  11. class ProductType
  12. {
  13.     use Timestapable;
  14.     use base64Field;
  15.     
  16.     #[ORM\Id]
  17.     #[ORM\GeneratedValue]
  18.     #[ORM\Column]
  19.     private ?int $id null;
  20.     #[ORM\Column(length255)]
  21.     private ?string $name null;
  22.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  23.     private ?string $description null;
  24.     #[ORM\Column(length255nullabletrue)]
  25.     private ?string $image_url null;
  26.     #[ORM\OneToMany(mappedBy'productType'targetEntityUtensil::class)]
  27.     private Collection $utensils;
  28.     public function __construct()
  29.     {
  30.         $this->utensils = 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 getDescription(): ?string
  46.     {
  47.         return $this->description;
  48.     }
  49.     public function setDescription(?string $description): self
  50.     {
  51.         $this->description $description;
  52.         return $this;
  53.     }
  54.     public function getImageUrl(): ?string
  55.     {
  56.         return $this->image_url;
  57.     }
  58.     public function setImageUrl(?string $image_url): self
  59.     {
  60.         $this->image_url $image_url;
  61.         return $this;
  62.     }
  63.     /**
  64.      * @return Collection<int, self>
  65.      */
  66.     public function getProductTypes(): Collection
  67.     {
  68.         return $this->productTypes;
  69.     }
  70.     /**
  71.      * @return Collection<int, Utensil>
  72.      */
  73.     public function getUtensils(): Collection
  74.     {
  75.         return $this->utensils;
  76.     }
  77.     public function addUtensil(Utensil $utensil): self
  78.     {
  79.         if (!$this->utensils->contains($utensil)) {
  80.             $this->utensils->add($utensil);
  81.             $utensil->setProductType($this);
  82.         }
  83.         return $this;
  84.     }
  85.     public function removeUtensil(Utensil $utensil): self
  86.     {
  87.         if ($this->utensils->removeElement($utensil)) {
  88.             // set the owning side to null (unless already changed)
  89.             if ($utensil->getProductType() === $this) {
  90.                 $utensil->setProductType(null);
  91.             }
  92.         }
  93.         return $this;
  94.     }
  95. }