src/Entity/UserEleveDocument.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\UserEleveDocumentRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Gedmo\Mapping\Annotation as Gedmo;
  6. use Symfony\Component\HttpFoundation\File\UploadedFile;
  7. /**
  8.  * @ORM\Entity(repositoryClass=UserEleveDocumentRepository::class)
  9.  * @ORM\HasLifecycleCallbacks
  10.  */
  11. class UserEleveDocument {
  12.     /**
  13.      * @ORM\Id
  14.      * @ORM\GeneratedValue
  15.      * @ORM\Column(type="integer")
  16.      */
  17.     private $id;
  18.     /**
  19.      * @ORM\Column(type="string", length=100, nullable=true)
  20.      */
  21.     private $nom;
  22.     /**
  23.      * chemin du dossier du fichier
  24.      * @ORM\Column(type="string", length=255, nullable=true)
  25.      */
  26.     private $path;
  27.     /**
  28.      * type du fichier
  29.      * @ORM\Column(type="string", length=25)
  30.      */
  31.     private $type;
  32.     /**
  33.      * taille du fichier
  34.      * @ORM\Column(type="integer", nullable=true)
  35.      */
  36.     private $size;
  37.     /**
  38.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="documents")
  39.      * @ORM\JoinColumn(nullable=false)
  40.      */
  41.     private $users;
  42.     /**
  43.      * type de document
  44.      * @ORM\Column(type="string", length=255)
  45.      */
  46.     private $doc;
  47.     /**
  48.      * @ORM\Column(type="datetime")
  49.      * @Gedmo\Timestampable(on="create")
  50.      */
  51.     private $createdAt;
  52.     /**
  53.      * @ORM\Column(type="datetime")
  54.      * @Gedmo\Timestampable(on="update")
  55.      */
  56.     private $updatedAt;
  57.     /**
  58.      * @ORM\Column(type="string", length=255, nullable=true)
  59.      */
  60.     private $neph;
  61.     public function getId(): ?int {
  62.         return $this->id;
  63.     }
  64.     public function getNom(): ?string {
  65.         return $this->nom;
  66.     }
  67.     public function setNom(string $nom): self {
  68.         $this->nom $nom;
  69.         return $this;
  70.     }
  71.     public function getPath(): ?string {
  72.         return $this->path;
  73.     }
  74.     public function setPath(string $path): self {
  75.         $this->path $path;
  76.         return $this;
  77.     }
  78.     public function getType(): ?string {
  79.         return $this->type;
  80.     }
  81.     public function setType(string $type): self {
  82.         $this->type $type;
  83.         return $this;
  84.     }
  85.     public function getSize(): ?int {
  86.         return $this->size;
  87.     }
  88.     public function setSize(int $size): self {
  89.         $this->size $size;
  90.         return $this;
  91.     }
  92.     public function getUsers(): ?User {
  93.         return $this->users;
  94.     }
  95.     public function setUsers(?User $users): self {
  96.         $this->users $users;
  97.         return $this;
  98.     }
  99.     public function getDoc(): ?string {
  100.         return $this->doc;
  101.     }
  102.     public function setDoc(string $doc): self {
  103.         $this->doc $doc;
  104.         return $this;
  105.     }
  106.     public function getNeph(): ?string {
  107.         return $this->neph;
  108.     }
  109.     public function setNeph(?string $neph): self {
  110.         $this->neph $neph;
  111.         return $this;
  112.     }
  113.     public function getCreatedAt(): ?\DateTimeInterface {
  114.         return $this->createdAt;
  115.     }
  116.     public function setCreatedAt(?\DateTimeInterface $createdAt): self {
  117.         $this->createdAt $createdAt;
  118.                                                                      
  119.         return $this;
  120.     }
  121.     public function getUpdatedAt(): ?\DateTimeInterface {
  122.         return $this->updatedAt;
  123.     }
  124.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self {
  125.         $this->updatedAt $updatedAt;
  126.                                                                      
  127.         return $this;
  128.     }
  129.     public function getDir(): ?string
  130.     {
  131.         return $this->getUsers()->getDir() .'/documents/';
  132.     }
  133.     public function getRealPath(): ?string
  134.     {
  135.         return $this->getDir() . $this->getPath();
  136.     }
  137.     /**
  138.      * @ORM\PostRemove()
  139.      */
  140.     public function removeFile(){
  141.         if (file_exists($this->getRealPath())) {
  142.             unlink($this->getRealPath());
  143.         }
  144.     }
  145. }