<?phpnamespace App\Entity;use DateTime;use Doctrine\ORM\Mapping as ORM;use Symfony\Component\HttpFoundation\File\File;use Symfony\Component\Validator\Constraints as Assert;use Vich\UploaderBundle\Mapping\Annotation as Vich;/** * @Vich\Uploadable */#[ORM\Entity(repositoryClass: 'App\Repository\ItemPhotoRepository')]#[ORM\Table(name: 'item_photo')]class ItemPhoto{ #[ORM\Column(type: 'boolean')] private bool $isDeleted = false; #[ORM\Column(name: 'createdAt', type: 'datetime')] private DateTime $createdAt; #[ORM\ManyToOne(targetEntity: Item::class, inversedBy: 'itemPhotos')] #[ORM\JoinColumn(nullable: false)] private Item $item; #[ORM\Id] #[ORM\Column(name: 'id', type: 'integer')] #[ORM\GeneratedValue(strategy: 'AUTO')] private ?int $id = null; /** * @Vich\UploadableField(mapping="itemPhoto", fileNameProperty="itemPhotoFileName", size="itemPhotoFileSize") */ #[Assert\File(maxSize: '1024k')] private ?File $itemPhotoFile = null; #[ORM\Column(type: 'string', length: 255, nullable: true)] private ?string $itemPhotoFileName = null; #[ORM\Column(type: 'integer', nullable: true)] private ?int $itemPhotoFileSize = null; #[ORM\Column(type: 'datetime', nullable: true)] private ?DateTime $itemPhotoFileUpdatedAt; public function __construct() { $this->createdAt = new DateTime(); } public function __toString() { return "#" . $this->id . " - " . $this->itemPhotoFileName; } /** * If manually uploading a file (i.e. not using Symfony Form) ensure an instance * of 'UploadedFile' is injected into this setter to trigger the update. If this * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter * must be able to accept an instance of 'File' as the bundle will inject one here * during Doctrine hydration. * * @param File|\Symfony\Component\HttpFoundation\File\UploadedFile $image */ public function setItemPhotoFile(File $image = null) { $this->itemPhotoFile = $image; if (null !== $image) { // It is required that at least one field changes if you are using doctrine // otherwise the event listeners won't be called and the file is lost $this->itemPhotoFileUpdatedAt = new \DateTime(); } } public function getItemPhotoFile() { return $this->itemPhotoFile; } /** * Get id * * @return int */ public function getId() { return $this->id; } /** * Set createdAt * * @param DateTime $createdAt * * @return ItemPhoto */ public function setCreatedAt($createdAt) { $this->createdAt = $createdAt; return $this; } /** * Get createdAt * * @return DateTime */ public function getCreatedAt() { return $this->createdAt; } /** * Set itemPhotoFileName * * @param string $itemPhotoFileName * * @return ItemPhoto */ public function setItemPhotoFileName($itemPhotoFileName) { $this->itemPhotoFileName = $itemPhotoFileName; return $this; } /** * Get itemPhotoFileName * * @return string */ public function getItemPhotoFileName() { return $this->itemPhotoFileName; } /** * Set itemPhotoFileSize * * @param integer $itemPhotoFileSize * * @return ItemPhoto */ public function setItemPhotoFileSize($itemPhotoFileSize) { $this->itemPhotoFileSize = $itemPhotoFileSize; return $this; } /** * Get itemPhotoFileSize * * @return integer */ public function getItemPhotoFileSize() { return $this->itemPhotoFileSize; } /** * Set itemPhotoFileUpdatedAt * * @param DateTime $itemPhotoFileUpdatedAt * * @return ItemPhoto */ public function setItemPhotoFileUpdatedAt($itemPhotoFileUpdatedAt) { $this->itemPhotoFileUpdatedAt = $itemPhotoFileUpdatedAt; return $this; } /** * Get itemPhotoFileUpdatedAt * * @return DateTime */ public function getItemPhotoFileUpdatedAt() { return $this->itemPhotoFileUpdatedAt; } /** * Set item * * @param \App\Entity\Item $item * * @return ItemPhoto */ public function setItem(\App\Entity\Item $item) { $this->item = $item; return $this; } /** * Get item * * @return \App\Entity\Item */ public function getItem() { return $this->item; } /** * Set isDeleted * * @param boolean $isDeleted * * @return ItemPhoto */ public function setIsDeleted($isDeleted) { $this->isDeleted = $isDeleted; return $this; } /** * Get isDeleted * * @return boolean */ public function getIsDeleted() { return $this->isDeleted; }}