<?phpnamespace App\Entity;use App\Repository\ArtistRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;/** * @ORM\Entity(repositoryClass=ArtistRepository::class) */class Artist{ /** * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") */ private $id; /** * @ORM\Column(type="string", length=255) */ private $name; /** * @ORM\ManyToMany(targetEntity=Vinyl::class, mappedBy="artists") */ private $vinyls; /** * @ORM\ManyToMany(targetEntity=Cd::class, mappedBy="artists") */ private $cds; /** * @ORM\Column(type="string", length=255) */ private $slug; /** * @ORM\ManyToMany(targetEntity=Track::class, mappedBy="artists") */ private $tracks; public function __construct() { $this->vinyls = new ArrayCollection(); $this->cds = new ArrayCollection(); $this->tracks = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function getName(): ?string { return $this->name; } public function setName(string $name): self { $this->name = $name; return $this; } /** * @return Collection|Vinyl[] */ public function getVinyls(): Collection { return $this->vinyls; } public function addVinyl(Vinyl $vinyl): self { if (!$this->vinyls->contains($vinyl)) { $this->vinyls[] = $vinyl; $vinyl->addArtist($this); } return $this; } public function removeVinyl(Vinyl $vinyl): self { if ($this->vinyls->removeElement($vinyl)) { $vinyl->removeArtist($this); } return $this; } /** * @return Collection|Cd[] */ public function getCds(): Collection { return $this->cds; } public function addCd(Cd $cd): self { if (!$this->cds->contains($cd)) { $this->cds[] = $cd; $cd->addArtist($this); } return $this; } public function removeCd(Cd $cd): self { if ($this->cds->removeElement($cd)) { $cd->removeArtist($this); } return $this; } public function getSlug(): ?string { return $this->slug; } public function setSlug(string $slug): self { $this->slug = $slug; return $this; } public function __toString() { return $this->name; } /** * @return Collection|Track[] */ public function getTracks(): Collection { return $this->tracks; } public function addTrack(Track $track): self { if (!$this->tracks->contains($track)) { $this->tracks[] = $track; $track->addArtist($this); } return $this; } public function removeTrack(Track $track): self { if ($this->tracks->removeElement($track)) { $track->removeArtist($this); } return $this; }}