src/Entity/Category.php line 17
<?phpnamespace App\Entity;use App\Entity\Trait\MainTranslationTrait;use App\Entity\Translation\CategoryTranslation;use App\Entity\Translation\ProductTranslation;use App\Repository\CategoryRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;use Gedmo\Translatable\Translatable;use Gedmo\Mapping\Annotation as Gedmo;#[Gedmo\TranslationEntity(class: self::TRANSLATION_ENTITY)]#[ORM\Entity(repositoryClass: CategoryRepository::class)]class Category implements Translatable{use MainTranslationTrait;const TRANSLATION_ENTITY = CategoryTranslation::class;public function __toString(): string{return $this->title ?? '';}#[ORM\Id]#[ORM\GeneratedValue]#[ORM\Column]private ?int $id = null;#[ORM\Column(type: 'string',nullable: true)]#[Gedmo\Translatable]private ?string $title = null;#[ORM\OneToMany(mappedBy: 'category', targetEntity: Product::class)]private Collection $products;public function __construct(){$this->products = new ArrayCollection();}public function getId(): ?int{return $this->id;}public function getProducts(): Collection{return $this->products;}public function addProduct(Product $product): self{if (!$this->products->contains($product)) {$this->products->add($product);$product->setCategory($this);}return $this;}public function removeProduct(Product $product): self{if ($this->products->removeElement($product)) {if ($product->getCategory() === $this) {$product->setCategory(null);}}return $this;}public function getTitle(): ?string{return $this->title;}public function setTitle(?string $title): self{$this->title = $title;return $this;}}