<?php
namespace App\Entity;
use App\Entity\Sortable\Sortable;
use App\Entity\Sortable\SortableInterface;
use App\Repository\ArtistRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Uid\Uuid;
/**
* @ORM\Entity(repositoryClass=ArtistRepository::class)
* @ORM\Table(indexes={@ORM\Index(name="name_idx", columns={"name"})})
*/
class Artist implements SortableInterface
{
use Sortable;
/**
* @ORM\Id
* @ORM\Column(type="uuid", unique=true)
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* @ORM\ManyToMany(targetEntity=Image::class, cascade={"persist", "remove"}, orphanRemoval=true)
*/
private $images;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $description;
/**
* @ORM\OneToMany(targetEntity=Lineup::class, mappedBy="artist")
* @ORM\OrderBy({"startAt" = "ASC"})
*/
private $lineups;
public function __construct()
{
$this->id = Uuid::v4();
$this->images = new ArrayCollection();
$this->lineups = new ArrayCollection();
}
public function getId(): string
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
/**
* @return Collection<int, Image>
*/
public function getImages(): Collection
{
return $this->images;
}
public function addImage(Image $image): self
{
if (!$this->images->contains($image)) {
$this->images[] = $image;
}
return $this;
}
public function removeImage(Image $image): self
{
$this->images->removeElement($image);
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
/**
* @return Collection<int, Lineup>
*/
public function getLineups(): Collection
{
return $this->lineups;
}
public function addLineup(Lineup $lineup): self
{
if (!$this->lineups->contains($lineup)) {
$this->lineups[] = $lineup;
$lineup->setArtist($this);
}
return $this;
}
public function removeLineup(Lineup $lineup): self
{
if ($this->lineups->removeElement($lineup)) {
// set the owning side to null (unless already changed)
if ($lineup->getArtist() === $this) {
$lineup->setArtist(null);
}
}
return $this;
}
}