src/Entity/Vinyl.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Product;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use App\Repository\VinylRepository;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. /**
  9.  * @ORM\Entity(repositoryClass=VinylRepository::class)
  10.  */
  11. class Vinyl extends Product
  12. {
  13.     /**
  14.      * @ORM\ManyToOne(targetEntity=Label::class, inversedBy="vinyls")
  15.      * @ORM\JoinColumn(nullable=false)
  16.      * @ORM\OrderBy({"name" = "ASC"})
  17.      */
  18.     private $label;
  19.     /**
  20.      * @ORM\ManyToMany(targetEntity=Style::class, inversedBy="vinyls", fetch="LAZY")
  21.      * @ORM\OrderBy({"name" = "ASC"})
  22.      */
  23.     private $styles;
  24.     /**
  25.      * @ORM\Column(type="smallint")
  26.      */
  27.     private $format;
  28.     /**
  29.      * @ORM\Column(type="smallint")
  30.      */
  31.     private $year;
  32.     /**
  33.      * @ORM\ManyToMany(targetEntity=Artist::class, inversedBy="vinyls")
  34.      * @ORM\OrderBy({"name" = "ASC"})
  35.      */
  36.     private $artists;
  37.     /**
  38.      * @ORM\Column(type="string", length=255)
  39.      */
  40.     private $state;
  41.     /**
  42.      * @ORM\Column(type="string", length=255, nullable=true)
  43.      */
  44.     private $img;
  45.     /**
  46.      * @ORM\OneToMany(targetEntity=Track::class, mappedBy="vinyl", orphanRemoval=true, cascade={"persist"}, fetch="LAZY")
  47.      */
  48.     private $tracks;
  49.     /**
  50.      * @ORM\Column(type="smallint")
  51.      */
  52.     private $nbItems;
  53.     public function __construct()
  54.     {
  55.         $this->styles = new ArrayCollection();
  56.         $this->artists = new ArrayCollection();
  57.         $this->tracks = new ArrayCollection();
  58.         parent::__construct();
  59.     }
  60.     public function getLabel(): ?Label
  61.     {
  62.         return $this->label;
  63.     }
  64.     public function setLabel(?Label $label): self
  65.     {
  66.         $this->label $label;
  67.         return $this;
  68.     }
  69.     /**
  70.      * @return Collection|Style[]
  71.      */
  72.     public function getStyles(): Collection
  73.     {
  74.         return $this->styles;
  75.     }
  76.     public function addStyle(Style $style): self
  77.     {
  78.         if (!$this->styles->contains($style)) {
  79.             $this->styles[] = $style;
  80.         }
  81.         return $this;
  82.     }
  83.     public function removeStyle(Style $style): self
  84.     {
  85.         $this->styles->removeElement($style);
  86.         return $this;
  87.     }
  88.     public function getFormat(): ?int
  89.     {
  90.         return $this->format;
  91.     }
  92.     public function setFormat(int $format): self
  93.     {
  94.         $this->format $format;
  95.         return $this;
  96.     }
  97.     public function getYear(): ?int
  98.     {
  99.         return $this->year;
  100.     }
  101.     public function setYear(int $year): self
  102.     {
  103.         $this->year $year;
  104.         return $this;
  105.     }
  106.     /**
  107.      * @return Collection|Artist[]
  108.      */
  109.     public function getArtists(): Collection
  110.     {
  111.         return $this->artists;
  112.     }
  113.     public function addArtist(Artist $artist): self
  114.     {
  115.         if (!$this->artists->contains($artist)) {
  116.             $this->artists[] = $artist;
  117.         }
  118.         return $this;
  119.     }
  120.     public function removeArtist(Artist $artist): self
  121.     {
  122.         $this->artists->removeElement($artist);
  123.         return $this;
  124.     }
  125.     public function getState(): ?string
  126.     {
  127.         return $this->state;
  128.     }
  129.     public function setState(string $state): self
  130.     {
  131.         $this->state $state;
  132.         return $this;
  133.     }
  134.     public function getImg(): ?string
  135.     {
  136.         return $this->img;
  137.     }
  138.     public function setImg(?string $img): self
  139.     {
  140.         $this->img $img;
  141.         return $this;
  142.     }
  143.     /**
  144.      * @return Collection|Track[]
  145.      */
  146.     public function getTracks(): Collection
  147.     {
  148.         return $this->tracks;
  149.     }
  150.     public function addTrack(Track $track): self
  151.     {
  152.         if (!$this->tracks->contains($track)) {
  153.             $this->tracks[] = $track;
  154.             $track->setVinyl($this);
  155.         }
  156.         return $this;
  157.     }
  158.     /**
  159.      * @param Track $track
  160.      * 
  161.      * @return self
  162.      */
  163.     public function removeTrack(Track $track): self
  164.     {
  165.         if ($this->tracks->removeElement($track)) {
  166.             // set the owning side to null (unless already changed)
  167.             if ($track->getVinyl() === $this) {
  168.                 $track->setVinyl(null);
  169.             }
  170.         }
  171.         return $this;
  172.     }
  173.     public function getNbItems(): ?int
  174.     {
  175.         return $this->nbItems;
  176.     }
  177.     public function setNbItems(int $nbItems): self
  178.     {
  179.         $this->nbItems $nbItems;
  180.         return $this;
  181.     }
  182. }