<?php
namespace App\Entity;
use App\Entity\Product;
use Doctrine\ORM\Mapping as ORM;
use App\Repository\VinylRepository;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\ArrayCollection;
/**
* @ORM\Entity(repositoryClass=VinylRepository::class)
*/
class Vinyl extends Product
{
/**
* @ORM\ManyToOne(targetEntity=Label::class, inversedBy="vinyls")
* @ORM\JoinColumn(nullable=false)
* @ORM\OrderBy({"name" = "ASC"})
*/
private $label;
/**
* @ORM\ManyToMany(targetEntity=Style::class, inversedBy="vinyls", fetch="LAZY")
* @ORM\OrderBy({"name" = "ASC"})
*/
private $styles;
/**
* @ORM\Column(type="smallint")
*/
private $format;
/**
* @ORM\Column(type="smallint")
*/
private $year;
/**
* @ORM\ManyToMany(targetEntity=Artist::class, inversedBy="vinyls")
* @ORM\OrderBy({"name" = "ASC"})
*/
private $artists;
/**
* @ORM\Column(type="string", length=255)
*/
private $state;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $img;
/**
* @ORM\OneToMany(targetEntity=Track::class, mappedBy="vinyl", orphanRemoval=true, cascade={"persist"}, fetch="LAZY")
*/
private $tracks;
/**
* @ORM\Column(type="smallint")
*/
private $nbItems;
public function __construct()
{
$this->styles = new ArrayCollection();
$this->artists = new ArrayCollection();
$this->tracks = new ArrayCollection();
parent::__construct();
}
public function getLabel(): ?Label
{
return $this->label;
}
public function setLabel(?Label $label): self
{
$this->label = $label;
return $this;
}
/**
* @return Collection|Style[]
*/
public function getStyles(): Collection
{
return $this->styles;
}
public function addStyle(Style $style): self
{
if (!$this->styles->contains($style)) {
$this->styles[] = $style;
}
return $this;
}
public function removeStyle(Style $style): self
{
$this->styles->removeElement($style);
return $this;
}
public function getFormat(): ?int
{
return $this->format;
}
public function setFormat(int $format): self
{
$this->format = $format;
return $this;
}
public function getYear(): ?int
{
return $this->year;
}
public function setYear(int $year): self
{
$this->year = $year;
return $this;
}
/**
* @return Collection|Artist[]
*/
public function getArtists(): Collection
{
return $this->artists;
}
public function addArtist(Artist $artist): self
{
if (!$this->artists->contains($artist)) {
$this->artists[] = $artist;
}
return $this;
}
public function removeArtist(Artist $artist): self
{
$this->artists->removeElement($artist);
return $this;
}
public function getState(): ?string
{
return $this->state;
}
public function setState(string $state): self
{
$this->state = $state;
return $this;
}
public function getImg(): ?string
{
return $this->img;
}
public function setImg(?string $img): self
{
$this->img = $img;
return $this;
}
/**
* @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->setVinyl($this);
}
return $this;
}
/**
* @param Track $track
*
* @return self
*/
public function removeTrack(Track $track): self
{
if ($this->tracks->removeElement($track)) {
// set the owning side to null (unless already changed)
if ($track->getVinyl() === $this) {
$track->setVinyl(null);
}
}
return $this;
}
public function getNbItems(): ?int
{
return $this->nbItems;
}
public function setNbItems(int $nbItems): self
{
$this->nbItems = $nbItems;
return $this;
}
}