src/Entity/Instrument.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\InstrumentRepository;
  4. use DateTimeImmutable;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\DBAL\Types\Types;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Component\HttpFoundation\File\File;
  10. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  11. #[ORM\Entity(repositoryClassInstrumentRepository::class)]
  12. #[Vich\Uploadable]
  13. class Instrument
  14. {
  15.     #[ORM\Id]
  16.     #[ORM\GeneratedValue]
  17.     #[ORM\Column]
  18.     private ?int $id null;
  19.     #[ORM\Column(length255nullabletrue)]
  20.     private ?string $name null;
  21.     #[ORM\Column(length255nullabletrue)]
  22.     private ?string $picture null;
  23.     #[Vich\UploadableField(mapping'instrument'fileNameProperty'picture')]
  24.     private ?File $imageFile null;
  25.     #[ORM\ManyToOne(inversedBy'instruments')]
  26.     #[ORM\JoinColumn(nullablefalse)]
  27.     private ?Category $category null;
  28.     #[ORM\ManyToOne(inversedBy'instruments')]
  29.     #[ORM\JoinColumn(nullablefalse)]
  30.     private ?Company $company null;
  31.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  32.     private ?\DateTimeInterface $releaseAt null;
  33.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  34.     private ?string $description null;
  35.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  36.     private ?string $summary null;
  37.     #[ORM\Column(length255)]
  38.     private ?string $slug null;
  39.     #[ORM\OneToMany(mappedBy'instrument'targetEntitySound::class)]
  40.     private Collection $sounds;
  41.     #[ORM\Column(nullabletrue)]
  42.     private ?\DateTimeImmutable $updatedAt null;
  43.     public function __construct()
  44.     {
  45.         $this->sounds = new ArrayCollection();
  46.     }
  47.     public function getId(): ?int
  48.     {
  49.         return $this->id;
  50.     }
  51.     public function getName(): ?string
  52.     {
  53.         return $this->name;
  54.     }
  55.     public function setName(?string $name): self
  56.     {
  57.         $this->name $name;
  58.         return $this;
  59.     }
  60.     /**
  61.      * @return File|null
  62.      */
  63.     public function getImageFile(): ?File
  64.     {
  65.         return $this->imageFile;
  66.     }
  67.     /**
  68.      * @param File|null $imageFile
  69.      */
  70.     public function setImageFile(?File $imageFile): void
  71.     {
  72.         $this->imageFile $imageFile;
  73.         if (null !== $imageFile) {
  74.             // It is required that at least one field changes if you are using doctrine
  75.             // otherwise the event listeners won't be called and the file is lost
  76.             $this->updatedAt = new DateTimeImmutable();
  77.         }
  78.     }
  79.     public function getPicture(): ?string
  80.     {
  81.         return $this->picture;
  82.     }
  83.     public function setPicture(?string $picture): self
  84.     {
  85.         $this->picture $picture;
  86.         return $this;
  87.     }
  88.     public function getCategory(): ?Category
  89.     {
  90.         return $this->category;
  91.     }
  92.     public function setCategory(?Category $category): self
  93.     {
  94.         $this->category $category;
  95.         return $this;
  96.     }
  97.     public function getCompany(): ?Company
  98.     {
  99.         return $this->company;
  100.     }
  101.     public function setCompany(?Company $company): self
  102.     {
  103.         $this->company $company;
  104.         return $this;
  105.     }
  106.     public function getReleaseAt(): ?\DateTimeInterface
  107.     {
  108.         return $this->releaseAt;
  109.     }
  110.     public function setReleaseAt(?\DateTimeInterface $releaseAt): self
  111.     {
  112.         $this->releaseAt $releaseAt;
  113.         return $this;
  114.     }
  115.     public function getDescription(): ?string
  116.     {
  117.         return $this->description;
  118.     }
  119.     public function setDescription(?string $description): self
  120.     {
  121.         $this->description $description;
  122.         return $this;
  123.     }
  124.     public function getSummary(): ?string
  125.     {
  126.         return $this->summary;
  127.     }
  128.     public function setSummary(?string $summary): self
  129.     {
  130.         $this->summary $summary;
  131.         return $this;
  132.     }
  133.     public function getSlug(): ?string
  134.     {
  135.         return $this->slug;
  136.     }
  137.     public function setSlug(string $slug): self
  138.     {
  139.         $this->slug $slug;
  140.         return $this;
  141.     }
  142.     /**
  143.      * @return Collection<int, Sound>
  144.      */
  145.     public function getSounds(): Collection
  146.     {
  147.         return $this->sounds;
  148.     }
  149.     public function addSound(Sound $sound): self
  150.     {
  151.         if (!$this->sounds->contains($sound)) {
  152.             $this->sounds->add($sound);
  153.             $sound->setInstrument($this);
  154.         }
  155.         return $this;
  156.     }
  157.     public function removeSound(Sound $sound): self
  158.     {
  159.         if ($this->sounds->removeElement($sound)) {
  160.             // set the owning side to null (unless already changed)
  161.             if ($sound->getInstrument() === $this) {
  162.                 $sound->setInstrument(null);
  163.             }
  164.         }
  165.         return $this;
  166.     }
  167.     public function getUpdatedAt(): ?\DateTimeImmutable
  168.     {
  169.         return $this->updatedAt;
  170.     }
  171.     public function setUpdatedAt(?\DateTimeImmutable $updatedAt): static
  172.     {
  173.         $this->updatedAt $updatedAt;
  174.         return $this;
  175.     }
  176. }