<?phpnamespace App\Entity;use App\Repository\CategoryRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;use Symfony\Component\HttpFoundation\File\File;use Vich\UploaderBundle\Mapping\Annotation as Vich;#[ORM\Entity(repositoryClass: CategoryRepository::class)]#[Vich\Uploadable]class Category{ #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column(type: 'integer')] private ?int $id = null; #[ORM\Column(type: 'string', length: 255)] private ?string $name = null; #[ORM\ManyToMany(targetEntity: Product::class, inversedBy: 'categories')] private Collection $products; #[Vich\UploadableField(mapping: 'category_image', fileNameProperty: 'imageName')] private ?File $imageFile = null; #[ORM\Column(type: 'string', length: 255, nullable: true)] private ?string $imageName = null; #[ORM\Column(type: 'datetime', nullable: true)] private ?\DateTimeInterface $updatedAt = null; public function __construct() { $this->products = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function getName(): ?string { return $this->name; } public function setName(string $name): self { $this->name = $name; return $this; } /** * @return Collection<int, Product> */ public function getProducts(): Collection { return $this->products; } public function addProduct(Product $product): self { if (!$this->products->contains($product)) { $this->products[] = $product; } return $this; } public function removeProduct(Product $product): self { $this->products->removeElement($product); return $this; } public function getImageFile(): ?File { return $this->imageFile; } public function setImageFile(?File $imageFile): self { $this->imageFile = $imageFile; if ($imageFile) { $this->updatedAt = new \DateTimeImmutable(); } return $this; } public function getImageName(): ?string { return $this->imageName; } public function setImageName(?string $imageName): self { $this->imageName = $imageName; return $this; } public function getUpdatedAt(): ?\DateTimeInterface { return $this->updatedAt; } public function setUpdatedAt(?\DateTimeInterface $updatedAt): self { $this->updatedAt = $updatedAt; return $this; }}