<?php
namespace App\Entity;
use App\Repository\FilmProjectImageRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
#[ORM\Entity(repositoryClass: FilmProjectImageRepository::class)]
#[Vich\Uploadable]
class FilmProjectImage
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $imagePath = null;
#[Vich\UploadableField(mapping:'project_gallery_images', fileNameProperty:'imagePath')]
private $imageFile;
#[ORM\ManyToOne(inversedBy: 'filmProjectImages')]
private ?FilmProject $filmProject = null;
public function getId(): ?int
{
return $this->id;
}
public function getImagePath(): ?string
{
return $this->imagePath;
}
public function setImagePath(?string $imagePath): self
{
$this->imagePath = $imagePath;
return $this;
}
public function getFilmProject(): ?FilmProject
{
return $this->filmProject;
}
public function setFilmProject(?FilmProject $filmProject): self
{
$this->filmProject = $filmProject;
return $this;
}
public function getImageFile()
{
return $this->imageFile;
}
public function setImageFile(File $image = null)
{
$this->imageFile = $image;
}
public function getImageUrl(): ?string
{
$url = '';
if ($this->imagePath) {
$url = '/uploads/projects/' . $this->imagePath;
}
return $url;
}
public function __toString()
{
if ($this->imagePath) {
return $this->imagePath;
}
return "";
}
}