<?php
namespace App\Entity;
use App\Repository\CategoryRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=CategoryRepository::class)
*/
class Category
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=128)
*/
private $name;
/**
* @ORM\Column(type="integer")
*/
private $wttId;
/**
* @ORM\OneToMany(targetEntity=Model::class, mappedBy="category")
*/
private $models;
/**
* @ORM\Column(type="string", length=16)
*/
private $type;
/**
* @ORM\OneToMany(targetEntity=CategorySetting::class, mappedBy="category", cascade={"persist"})
*/
private $settings;
/**
* @ORM\OneToMany(targetEntity=Option::class, mappedBy="category", cascade={"persist"})
*/
private $options;
/**
* @ORM\ManyToMany(targetEntity=Shop::class, mappedBy="categories", cascade={"persist"})
*/
private $shops;
public function __construct()
{
$this->models = new ArrayCollection();
$this->settings = new ArrayCollection();
$this->options = new ArrayCollection();
$this->shops = new ArrayCollection();
}
public function __toString()
{
return $this->getName();
}
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 getWttId(): ?int
{
return $this->wttId;
}
public function setWttId(int $wttId): self
{
$this->wttId = $wttId;
return $this;
}
/**
* @return Collection<int, Model>
*/
public function getModels(): Collection
{
return $this->models;
}
public function addModel(Model $model): self
{
if (!$this->models->contains($model)) {
$this->models[] = $model;
$model->setCategory($this);
}
return $this;
}
public function removeModel(Model $model): self
{
if ($this->models->removeElement($model)) {
// set the owning side to null (unless already changed)
if ($model->getCategory() === $this) {
$model->setCategory(null);
}
}
return $this;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(string $type): self
{
$this->type = $type;
return $this;
}
/**
* @return Collection<int, ShopSetting>
*/
public function getSettings(): Collection
{
return $this->settings;
}
public function addSetting(ShopSetting $setting): static
{
if (!$this->settings->contains($setting)) {
$this->settings->add($setting);
$setting->setCategory($this);
}
return $this;
}
public function removeSetting(ShopSetting $setting): static
{
if ($this->settings->removeElement($setting)) {
// set the owning side to null (unless already changed)
if ($setting->getCategory() === $this) {
$setting->setCategory(null);
}
}
return $this;
}
/**
* @return Collection<int, Option>
*/
public function getOptions(): Collection
{
return $this->options;
}
public function addOption(Option $option): static
{
if (!$this->options->contains($option)) {
$this->options->add($option);
}
return $this;
}
public function removeOption(Option $option): static
{
$this->options->removeElement($option);
return $this;
}
/**
* @return Collection<int, Shop>
*/
public function getShops(): Collection
{
return $this->shops;
}
public function addShop(Shop $shop): static
{
if (!$this->shops->contains($shop)) {
$this->shops->add($shop);
$shop->addCategory($this);
}
return $this;
}
public function removeShop(Shop $shop): static
{
if ($this->shops->removeElement($shop)) {
$shop->removeCategory($this);
}
return $this;
}
}