src/Entity/Artist.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ArtistRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity(repositoryClass=ArtistRepository::class)
  9.  */
  10. class Artist
  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\ManyToMany(targetEntity=Vinyl::class, mappedBy="artists")
  24.      */
  25.     private $vinyls;
  26.     /**
  27.      * @ORM\ManyToMany(targetEntity=Cd::class, mappedBy="artists")
  28.      */
  29.     private $cds;
  30.     /**
  31.      * @ORM\Column(type="string", length=255)
  32.      */
  33.     private $slug;
  34.     /**
  35.      * @ORM\ManyToMany(targetEntity=Track::class, mappedBy="artists")
  36.      */
  37.     private $tracks;
  38.     public function __construct()
  39.     {
  40.         $this->vinyls = new ArrayCollection();
  41.         $this->cds = new ArrayCollection();
  42.         $this->tracks = new ArrayCollection();
  43.     }
  44.     public function getId(): ?int
  45.     {
  46.         return $this->id;
  47.     }
  48.     public function getName(): ?string
  49.     {
  50.         return $this->name;
  51.     }
  52.     public function setName(string $name): self
  53.     {
  54.         $this->name $name;
  55.         return $this;
  56.     }
  57.     /**
  58.      * @return Collection|Vinyl[]
  59.      */
  60.     public function getVinyls(): Collection
  61.     {
  62.         return $this->vinyls;
  63.     }
  64.     public function addVinyl(Vinyl $vinyl): self
  65.     {
  66.         if (!$this->vinyls->contains($vinyl)) {
  67.             $this->vinyls[] = $vinyl;
  68.             $vinyl->addArtist($this);
  69.         }
  70.         return $this;
  71.     }
  72.     public function removeVinyl(Vinyl $vinyl): self
  73.     {
  74.         if ($this->vinyls->removeElement($vinyl)) {
  75.             $vinyl->removeArtist($this);
  76.         }
  77.         return $this;
  78.     }
  79.     /**
  80.      * @return Collection|Cd[]
  81.      */
  82.     public function getCds(): Collection
  83.     {
  84.         return $this->cds;
  85.     }
  86.     public function addCd(Cd $cd): self
  87.     {
  88.         if (!$this->cds->contains($cd)) {
  89.             $this->cds[] = $cd;
  90.             $cd->addArtist($this);
  91.         }
  92.         return $this;
  93.     }
  94.     public function removeCd(Cd $cd): self
  95.     {
  96.         if ($this->cds->removeElement($cd)) {
  97.             $cd->removeArtist($this);
  98.         }
  99.         return $this;
  100.     }
  101.     public function getSlug(): ?string
  102.     {
  103.         return $this->slug;
  104.     }
  105.     public function setSlug(string $slug): self
  106.     {
  107.         $this->slug $slug;
  108.         return $this;
  109.     }
  110.     public function __toString()
  111.     {
  112.         return $this->name;
  113.     }
  114.     /**
  115.      * @return Collection|Track[]
  116.      */
  117.     public function getTracks(): Collection
  118.     {
  119.         return $this->tracks;
  120.     }
  121.     public function addTrack(Track $track): self
  122.     {
  123.         if (!$this->tracks->contains($track)) {
  124.             $this->tracks[] = $track;
  125.             $track->addArtist($this);
  126.         }
  127.         return $this;
  128.     }
  129.     public function removeTrack(Track $track): self
  130.     {
  131.         if ($this->tracks->removeElement($track)) {
  132.             $track->removeArtist($this);
  133.         }
  134.         return $this;
  135.     }
  136. }