<?phpnamespace App\Entity;use App\Repository\LabelRepository;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=LabelRepository::class) * @ORM\Table(name="`label`") * @Vich\Uploadable */class Label{ /** * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") */ private $id; /** * @ORM\Column(type="string", length=255) */ private $nom; /** * @ORM\ManyToMany(targetEntity=Cuvee::class, mappedBy="labels") */ private $cuvees; /** * @ORM\Column(type="string", length=255, nullable=true) * */ private $image; /** * @Vich\UploadableField(mapping = "label_images", fileNameProperty = "image") */ private $imageFile; /** * @ORM\Column(type="datetime", nullable=true) */ private $date_modification; public function __construct() { $this->cuvees = new ArrayCollection(); } public function __toString() { return $this->nom; } public function getId(): ?int { return $this->id; } public function getNom(): ?string { return $this->nom; } public function setNom(string $nom): self { $this->nom = $nom; return $this; } /** * @return Collection<int, Cuvee> */ public function getCuvees(): Collection { return $this->cuvees; } public function addCuvee(Cuvee $cuvee): self { if (!$this->cuvees->contains($cuvee)) { $this->cuvees[] = $cuvee; $cuvee->addLabel($this); } return $this; } public function removeCuvee(Cuvee $cuvee): self { if ($this->cuvees->removeElement($cuvee)) { $cuvee->removeLabel($this); } return $this; } public function getImage(): ?string { return $this->image; } public function setImage(?string $image): self { $this->image = $image; return $this; } /** * 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|null $imageFile */ public function setImageFile(?File $imageFile = null): void { $this->imageFile = $imageFile; if (null !== $imageFile) { // 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->date_modification = new \DateTimeImmutable(); } } public function getImageFile(): ?File { return $this->imageFile; } public function getDateModification(): ?\DateTimeInterface { return $this->date_modification; } public function setDateModification(?\DateTimeInterface $date_modification): self { $this->date_modification = $date_modification; return $this; }}