src/Entity/Category.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CategoryRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity(repositoryClass=CategoryRepository::class)
  9.  */
  10. class Category
  11. {
  12.     /**
  13.      * @ORM\Id
  14.      * @ORM\GeneratedValue
  15.      * @ORM\Column(type="integer")
  16.      */
  17.     private $id;
  18.     /**
  19.      * @ORM\Column(type="string", length=128)
  20.      */
  21.     private $name;
  22.     /**
  23.      * @ORM\Column(type="integer")
  24.      */
  25.     private $wttId;
  26.     /**
  27.      * @ORM\OneToMany(targetEntity=Model::class, mappedBy="category")
  28.      */
  29.     private $models;
  30.     /**
  31.      * @ORM\Column(type="string", length=16)
  32.      */
  33.     private $type;
  34.     /**
  35.      * @ORM\OneToMany(targetEntity=CategorySetting::class, mappedBy="category", cascade={"persist"})
  36.      */
  37.     private $settings;
  38.     /**
  39.      * @ORM\OneToMany(targetEntity=Option::class, mappedBy="category", cascade={"persist"})
  40.      */
  41.     private $options;
  42.     /**
  43.      * @ORM\ManyToMany(targetEntity=Shop::class, mappedBy="categories", cascade={"persist"})
  44.      */
  45.     private $shops;
  46.     public function __construct()
  47.     {
  48.         $this->models = new ArrayCollection();
  49.         $this->settings = new ArrayCollection();
  50.         $this->options = new ArrayCollection();
  51.         $this->shops = new ArrayCollection();
  52.     }
  53.     public function __toString()
  54.     {
  55.         return $this->getName();
  56.     }
  57.     public function getId(): ?int
  58.     {
  59.         return $this->id;
  60.     }
  61.     public function getName(): ?string
  62.     {
  63.         return $this->name;
  64.     }
  65.     public function setName(string $name): self
  66.     {
  67.         $this->name $name;
  68.         return $this;
  69.     }
  70.     public function getWttId(): ?int
  71.     {
  72.         return $this->wttId;
  73.     }
  74.     public function setWttId(int $wttId): self
  75.     {
  76.         $this->wttId $wttId;
  77.         return $this;
  78.     }
  79.     /**
  80.      * @return Collection<int, Model>
  81.      */
  82.     public function getModels(): Collection
  83.     {
  84.         return $this->models;
  85.     }
  86.     public function addModel(Model $model): self
  87.     {
  88.         if (!$this->models->contains($model)) {
  89.             $this->models[] = $model;
  90.             $model->setCategory($this);
  91.         }
  92.         return $this;
  93.     }
  94.     public function removeModel(Model $model): self
  95.     {
  96.         if ($this->models->removeElement($model)) {
  97.             // set the owning side to null (unless already changed)
  98.             if ($model->getCategory() === $this) {
  99.                 $model->setCategory(null);
  100.             }
  101.         }
  102.         return $this;
  103.     }
  104.     public function getType(): ?string
  105.     {
  106.         return $this->type;
  107.     }
  108.     public function setType(string $type): self
  109.     {
  110.         $this->type $type;
  111.         return $this;
  112.     }
  113.     /**
  114.      * @return Collection<int, ShopSetting>
  115.      */
  116.     public function getSettings(): Collection
  117.     {
  118.         return $this->settings;
  119.     }
  120.     public function addSetting(ShopSetting $setting): static
  121.     {
  122.         if (!$this->settings->contains($setting)) {
  123.             $this->settings->add($setting);
  124.             $setting->setCategory($this);
  125.         }
  126.         return $this;
  127.     }
  128.     public function removeSetting(ShopSetting $setting): static
  129.     {
  130.         if ($this->settings->removeElement($setting)) {
  131.             // set the owning side to null (unless already changed)
  132.             if ($setting->getCategory() === $this) {
  133.                 $setting->setCategory(null);
  134.             }
  135.         }
  136.         return $this;
  137.     }
  138.     /**
  139.      * @return Collection<int, Option>
  140.      */
  141.     public function getOptions(): Collection
  142.     {
  143.         return $this->options;
  144.     }
  145.     public function addOption(Option $option): static
  146.     {
  147.         if (!$this->options->contains($option)) {
  148.             $this->options->add($option);
  149.         }
  150.         return $this;
  151.     }
  152.     public function removeOption(Option $option): static
  153.     {
  154.         $this->options->removeElement($option);
  155.         return $this;
  156.     }
  157.     /**
  158.      * @return Collection<int, Shop>
  159.      */
  160.     public function getShops(): Collection
  161.     {
  162.         return $this->shops;
  163.     }
  164.     public function addShop(Shop $shop): static
  165.     {
  166.         if (!$this->shops->contains($shop)) {
  167.             $this->shops->add($shop);
  168.             $shop->addCategory($this);
  169.         }
  170.         return $this;
  171.     }
  172.     public function removeShop(Shop $shop): static
  173.     {
  174.         if ($this->shops->removeElement($shop)) {
  175.             $shop->removeCategory($this);
  176.         }
  177.         return $this;
  178.     }
  179. }