src/Entity/CategoryAccessory.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CategoryAccessoryRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity(repositoryClass=CategoryAccessoryRepository::class)
  9.  */
  10. class CategoryAccessory
  11. {
  12.     /**
  13.      * @ORM\Id
  14.      * @ORM\GeneratedValue
  15.      * @ORM\Column(type="integer")
  16.      */
  17.     private $id;
  18.     /**
  19.      * @ORM\Column(type="string", length=255)
  20.      */
  21.     private $title;
  22.     /**
  23.      * @ORM\Column(type="string", length=255)
  24.      */
  25.     private $icon;
  26.     /**
  27.      * @ORM\OneToMany(targetEntity=Accessory::class, mappedBy="categoryAccessory")
  28.      */
  29.     private $accessory;
  30.     public function __construct()
  31.     {
  32.         $this->accessory = new ArrayCollection();
  33.     }
  34.     public function getId(): ?int
  35.     {
  36.         return $this->id;
  37.     }
  38.     public function getTitle(): ?string
  39.     {
  40.         return $this->title;
  41.     }
  42.     public function setTitle(string $title): self
  43.     {
  44.         $this->title $title;
  45.         return $this;
  46.     }
  47.     public function getIcon(): ?string
  48.     {
  49.         return $this->icon;
  50.     }
  51.     public function setIcon(string $icon): self
  52.     {
  53.         $this->icon $icon;
  54.         return $this;
  55.     }
  56.     /**
  57.      * @return Collection<int, Accessory>
  58.      */
  59.     public function getAccessory(): Collection
  60.     {
  61.         return $this->accessory;
  62.     }
  63.     public function addAccessory(Accessory $accessory): self
  64.     {
  65.         if (!$this->accessory->contains($accessory)) {
  66.             $this->accessory[] = $accessory;
  67.             $accessory->setCategoryAccessory($this);
  68.         }
  69.         return $this;
  70.     }
  71.     public function removeAccessory(Accessory $accessory): self
  72.     {
  73.         if ($this->accessory->removeElement($accessory)) {
  74.             // set the owning side to null (unless already changed)
  75.             if ($accessory->getCategoryAccessory() === $this) {
  76.                 $accessory->setCategoryAccessory(null);
  77.             }
  78.         }
  79.         return $this;
  80.     }
  81. }