src/Entity/Label.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\LabelRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity(repositoryClass=LabelRepository::class)
  9.  */
  10. class Label
  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 $name;
  22.     /**
  23.      * @ORM\OneToMany(targetEntity=Vinyl::class, mappedBy="label")
  24.      */
  25.     private $vinyls;
  26.     /**
  27.      * @ORM\OneToMany(targetEntity=Cd::class, mappedBy="label")
  28.      */
  29.     private $cds;
  30.     /**
  31.      * @ORM\Column(type="string", length=255)
  32.      */
  33.     private $slug;
  34.     public function __construct()
  35.     {
  36.         $this->vinyls = new ArrayCollection();
  37.         $this->cds = new ArrayCollection();
  38.     }
  39.     public function getId(): ?int
  40.     {
  41.         return $this->id;
  42.     }
  43.     public function getName(): ?string
  44.     {
  45.         return $this->name;
  46.     }
  47.     public function setName(string $name): self
  48.     {
  49.         $this->name $name;
  50.         return $this;
  51.     }
  52.     /**
  53.      * @return Collection|Vinyl[]
  54.      */
  55.     public function getVinyls(): Collection
  56.     {
  57.         return $this->vinyls;
  58.     }
  59.     public function addVinyl(Vinyl $vinyl): self
  60.     {
  61.         if (!$this->vinyls->contains($vinyl)) {
  62.             $this->vinyls[] = $vinyl;
  63.             $vinyl->setLabel($this);
  64.         }
  65.         return $this;
  66.     }
  67.     public function removeVinyl(Vinyl $vinyl): self
  68.     {
  69.         if ($this->vinyls->removeElement($vinyl)) {
  70.             // set the owning side to null (unless already changed)
  71.             if ($vinyl->getLabel() === $this) {
  72.                 $vinyl->setLabel(null);
  73.             }
  74.         }
  75.         return $this;
  76.     }
  77.     /**
  78.      * @return Collection|Cd[]
  79.      */
  80.     public function getCds(): Collection
  81.     {
  82.         return $this->cds;
  83.     }
  84.     public function addCd(Cd $cd): self
  85.     {
  86.         if (!$this->cds->contains($cd)) {
  87.             $this->cds[] = $cd;
  88.             $cd->setLabel($this);
  89.         }
  90.         return $this;
  91.     }
  92.     public function removeCd(Cd $cd): self
  93.     {
  94.         if ($this->cds->removeElement($cd)) {
  95.             // set the owning side to null (unless already changed)
  96.             if ($cd->getLabel() === $this) {
  97.                 $cd->setLabel(null);
  98.             }
  99.         }
  100.         return $this;
  101.     }
  102.     public function getSlug(): ?string
  103.     {
  104.         return $this->slug;
  105.     }
  106.     public function setSlug(string $slug): self
  107.     {
  108.         $this->slug $slug;
  109.         return $this;
  110.     }
  111.     public function __toString()
  112.     {
  113.         return $this->name;
  114.     }
  115. }