<?phpnamespace App\Entity;use App\Repository\CategoryRepository;use DateTime;use Doctrine\DBAL\Types\Types;use Doctrine\ORM\Mapping as ORM;use Symfony\Component\HttpFoundation\File\File;use Symfony\Component\HttpFoundation\File\UploadedFile;use Vich\UploaderBundle\Mapping\Annotation as Vich;#[ORM\Entity(repositoryClass: CategoryRepository::class)]#[ORM\Table(name: 'category')]#[Vich\Uploadable]class Category { #[ORM\Id] #[ORM\GeneratedValue(strategy: "AUTO")] #[ORM\Column(type: Types::INTEGER)] private ?int $id; #[ORM\Column(type: Types::BOOLEAN)] private bool $isDeleted = false; #[ORM\Column(type: Types::STRING, length: 255)] private ?string $name; #[ORM\Column(type: Types::STRING, length: 255, nullable: true)] private ?string $categoryFileName; #[ORM\Column(type: Types::INTEGER, nullable: true)] private ?int $categoryFileSize; #[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)] private ?DateTime $categoryFileUpdatedAt; /** * NOTE: This is not a mapped field of entity metadata, just a simple property. */ #[Vich\UploadableField(mapping:'category', fileNameProperty:'categoryFileName', size:'categoryFileSize')] private? File $categoryFile; public function __toString() { return "#" . $this->id . " - " . $this->name; } public function getId(): ?int { return $this->id; } public function setIsDeleted(bool $isDeleted): static { $this->isDeleted = $isDeleted; return $this; } public function getIsDeleted(): bool { return $this->isDeleted; } public function setName(?string $name): static { $this->name = $name; return $this; } public function getName(): ?string { return $this->name; } public function setCategoryFileName(?string $categoryFileName): static { $this->categoryFileName = $categoryFileName; return $this; } public function getCategoryFileName(): ?string { return $this->categoryFileName; } public function setCategoryFileSize(?int $categoryFileSize): static { $this->categoryFileSize = $categoryFileSize; return $this; } public function getCategoryFileSize(): ?int { return $this->categoryFileSize; } public function setCategoryFileUpdatedAt(DateTime $categoryFileUpdatedAt): static { $this->categoryFileUpdatedAt = $categoryFileUpdatedAt; return $this; } public function getCategoryFileUpdatedAt(): DateTime { return $this->categoryFileUpdatedAt; } /** * 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. */ public function setCategoryFile(File|UploadedFile $image = null): static { $this->categoryFile = $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->categoryFileUpdatedAt = new \DateTime(); } return $this; } public function getCategoryFile(): ?File { return $this->categoryFile; }}