<?phpnamespace App\Entity;use App\Entity\Traits\TimeStampable;use App\Repository\DocumentRepository;use Doctrine\DBAL\Types\Types;use Doctrine\ORM\Mapping as ORM;use Symfony\Component\HttpFoundation\File\File;use Symfony\Component\Serializer\Annotation\Groups;use Vich\UploaderBundle\Mapping\Annotation as Vich;use Symfony\Component\Validator\Constraints as Assert;#[ORM\Entity(repositoryClass: DocumentRepository::class)]#[Vich\Uploadable]#[ORM\HasLifecycleCallbacks]class Document{ use TimeStampable; #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column] #[Groups(['documentProjet:read'])] private ?int $id = null; #[ORM\Column(length: 255, nullable:true)] #[Groups(['documentProjet:read'])] private ?string $titre = null; #[ORM\Column(length: 255)] #[Groups(['documentProjet:read'])] private ?string $file = null; #[ORM\ManyToOne(inversedBy: 'documents')] private ?Task $tache = null; #[Vich\UploadableField(mapping: 'document_projet', fileNameProperty: 'file')] #[Assert\NotBlank(message:"Veuillez remplir ce champ")] private ?File $imageFile = null; #[ORM\Column(nullable: true)] private ?\DateTimeImmutable $updatedAtFile = null; #[ORM\ManyToOne(inversedBy: 'documents')] private ?Projet $projet = null; #[ORM\Column(type: Types::TEXT, nullable: true)] #[Groups(['documentProjet:read'])] private ?string $description = null; #[ORM\ManyToOne(inversedBy: 'documents')] #[Groups(['documentProjet:read'])] #[Assert\NotBlank(message:"Veuillez remplir ce champ")] private ?DocumentType $typeDocument = null; #[Groups(['documentProjet:read'])] #[ORM\ManyToOne(inversedBy: 'documents')] private ?User $author = null; #[ORM\ManyToOne(inversedBy: 'documents')] private ?RateOfProgress $rateOfProgress = null; public function __construct() { $this->createdAt = new \DateTimeImmutable(); } public function getId(): ?int { return $this->id; } public function getTitre(): ?string { return $this->titre; } public function setTitre(?string $titre): static { $this->titre = $titre; return $this; } public function getFile(): ?string { return $this->file; } public function setFile(?string $file): static { $this->file = $file; return $this; } public function getTache(): ?Task { return $this->tache; } public function setTache(?Task $tache): static { $this->tache = $tache; 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->updatedAtFile = new \DateTimeImmutable(); } } public function getImageFile(): ?File { return $this->imageFile; } public function getProjet(): ?Projet { return $this->projet; } public function setProjet(?Projet $projet): static { $this->projet = $projet; return $this; } public function getDescription(): ?string { return $this->description; } public function setDescription(?string $description): static { $this->description = $description; return $this; } public function getTypeDocument(): ?DocumentType { return $this->typeDocument; } public function setTypeDocument(?DocumentType $typeDocument): static { $this->typeDocument = $typeDocument; return $this; } public function getAuthor(): ?User { return $this->author; } public function setAuthor(?User $author): static { $this->author = $author; return $this; } public function getRateOfProgress(): ?RateOfProgress { return $this->rateOfProgress; } public function setRateOfProgress(?RateOfProgress $rateOfProgress): static { $this->rateOfProgress = $rateOfProgress; return $this; }}