src/Entity/Album.php line 11

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\AlbumRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassAlbumRepository::class)]
  8. class Album
  9. {
  10.     #[ORM\Id]
  11.     #[ORM\GeneratedValue]
  12.     #[ORM\Column]
  13.     private ?int $id null;
  14.     #[ORM\Column(length255nullabletrue)]
  15.     private ?string $title null;
  16.     #[ORM\Column(length255nullabletrue)]
  17.     private ?string $date null;
  18.     #[ORM\Column(length255)]
  19.     private ?string $imageMain null;
  20.     #[ORM\OneToMany(mappedBy'albumId'targetEntityAlbumImage::class, orphanRemovaltruecascade: ['persist'])]
  21.     private Collection $albumImages;
  22.     #[ORM\ManyToOne(inversedBy'albums')]
  23.     #[ORM\JoinColumn(nullabletrue)]
  24.     private ?BranchOffice $branchOffice null;
  25.     public function __construct()
  26.     {
  27.         $this->albumImages = new ArrayCollection();
  28.     }
  29.     public function getId(): ?int
  30.     {
  31.         return $this->id;
  32.     }
  33.     public function getTitle(): ?string
  34.     {
  35.         return $this->title;
  36.     }
  37.     public function setTitle(?string $title): self
  38.     {
  39.         $this->title $title;
  40.         return $this;
  41.     }
  42.     public function getDate(): ?string
  43.     {
  44.         return $this->date;
  45.     }
  46.     public function setDate(?string $date): self
  47.     {
  48.         $this->date $date;
  49.         return $this;
  50.     }
  51.     public function getImageMain(): ?string
  52.     {
  53.         return $this->imageMain;
  54.     }
  55.     public function setImageMain(string $imageMain): self
  56.     {
  57.         $this->imageMain $imageMain;
  58.         return $this;
  59.     }
  60.     /**
  61.      * @return Collection<int, AlbumImage>
  62.      */
  63.     public function getAlbumImages(): Collection
  64.     {
  65.         return $this->albumImages;
  66.     }
  67.     public function addAlbumImage(AlbumImage $albumImage): self
  68.     {
  69.         if (!$this->albumImages->contains($albumImage)) {
  70.             $this->albumImages->add($albumImage);
  71.             $albumImage->setAlbumId($this);
  72.         }
  73.         return $this;
  74.     }
  75.     public function removeAlbumImage(AlbumImage $albumImage): self
  76.     {
  77.         if ($this->albumImages->removeElement($albumImage)) {
  78.             if ($albumImage->getAlbumId() === $this) {
  79.                 $albumImage->setAlbumId(null);
  80.             }
  81.         }
  82.         return $this;
  83.     }
  84.     public function getBranchOffice(): ?BranchOffice
  85.     {
  86.         return $this->branchOffice;
  87.     }
  88.     public function setBranchOffice(?BranchOffice $branchOffice): self
  89.     {
  90.         $this->branchOffice $branchOffice;
  91.         return $this;
  92.     }
  93.     public function __toString(): string
  94.     {
  95.         return $this->title;
  96.     }
  97.     public function getMultipleImages()
  98.     {
  99.         return null;
  100.     }
  101.     public function setMultipleImages(?array $uploadedImageNames)
  102.     {
  103.         if ($uploadedImageNames) {   
  104.             foreach ($uploadedImageNames as $imageName) {
  105.                 $albumImage = new AlbumImage();
  106.                 $albumImage->setImageUrl($imageName);
  107.                 $this->addAlbumImage($albumImage);
  108.             }
  109.         }
  110.     }
  111. }