<?php
namespace App\Entity;
use App\Repository\CategoryAccessoryRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=CategoryAccessoryRepository::class)
*/
class CategoryAccessory
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $title;
/**
* @ORM\Column(type="string", length=255)
*/
private $icon;
/**
* @ORM\OneToMany(targetEntity=Accessory::class, mappedBy="categoryAccessory")
*/
private $accessory;
public function __construct()
{
$this->accessory = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(string $title): self
{
$this->title = $title;
return $this;
}
public function getIcon(): ?string
{
return $this->icon;
}
public function setIcon(string $icon): self
{
$this->icon = $icon;
return $this;
}
/**
* @return Collection<int, Accessory>
*/
public function getAccessory(): Collection
{
return $this->accessory;
}
public function addAccessory(Accessory $accessory): self
{
if (!$this->accessory->contains($accessory)) {
$this->accessory[] = $accessory;
$accessory->setCategoryAccessory($this);
}
return $this;
}
public function removeAccessory(Accessory $accessory): self
{
if ($this->accessory->removeElement($accessory)) {
// set the owning side to null (unless already changed)
if ($accessory->getCategoryAccessory() === $this) {
$accessory->setCategoryAccessory(null);
}
}
return $this;
}
}