<?php
namespace App\Entity;
use App\Repository\UserEleveDocumentRepository;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\HttpFoundation\File\UploadedFile;
/**
* @ORM\Entity(repositoryClass=UserEleveDocumentRepository::class)
* @ORM\HasLifecycleCallbacks
*/
class UserEleveDocument {
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=100, nullable=true)
*/
private $nom;
/**
* chemin du dossier du fichier
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $path;
/**
* type du fichier
* @ORM\Column(type="string", length=25)
*/
private $type;
/**
* taille du fichier
* @ORM\Column(type="integer", nullable=true)
*/
private $size;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="documents")
* @ORM\JoinColumn(nullable=false)
*/
private $users;
/**
* type de document
* @ORM\Column(type="string", length=255)
*/
private $doc;
/**
* @ORM\Column(type="datetime")
* @Gedmo\Timestampable(on="create")
*/
private $createdAt;
/**
* @ORM\Column(type="datetime")
* @Gedmo\Timestampable(on="update")
*/
private $updatedAt;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $neph;
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;
}
public function getPath(): ?string {
return $this->path;
}
public function setPath(string $path): self {
$this->path = $path;
return $this;
}
public function getType(): ?string {
return $this->type;
}
public function setType(string $type): self {
$this->type = $type;
return $this;
}
public function getSize(): ?int {
return $this->size;
}
public function setSize(int $size): self {
$this->size = $size;
return $this;
}
public function getUsers(): ?User {
return $this->users;
}
public function setUsers(?User $users): self {
$this->users = $users;
return $this;
}
public function getDoc(): ?string {
return $this->doc;
}
public function setDoc(string $doc): self {
$this->doc = $doc;
return $this;
}
public function getNeph(): ?string {
return $this->neph;
}
public function setNeph(?string $neph): self {
$this->neph = $neph;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface {
return $this->createdAt;
}
public function setCreatedAt(?\DateTimeInterface $createdAt): self {
$this->createdAt = $createdAt;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface {
return $this->updatedAt;
}
public function setUpdatedAt(?\DateTimeInterface $updatedAt): self {
$this->updatedAt = $updatedAt;
return $this;
}
public function getDir(): ?string
{
return $this->getUsers()->getDir() .'/documents/';
}
public function getRealPath(): ?string
{
return $this->getDir() . $this->getPath();
}
/**
* @ORM\PostRemove()
*/
public function removeFile(){
if (file_exists($this->getRealPath())) {
unlink($this->getRealPath());
}
}
}