src/Entity/UserEnseignantDocument.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\UserEnseignantDocumentRepository;
  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=UserEnseignantDocumentRepository::class)
  9.  */
  10. class UserEnseignantDocument
  11. {
  12.     static $doc_values = ['cni''permis''autorisation''num_autorisation''avis_medical','kbis','rib','vigilance','contrat','rcpro'];
  13.     static $doc_values_txt = ['num_autorisation'];
  14.     /**
  15.      * @ORM\Id
  16.      * @ORM\GeneratedValue
  17.      * @ORM\Column(type="integer")
  18.      */
  19.     private $id;
  20.     /**
  21.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="userEnseignantDocuments")
  22.      * @ORM\JoinColumn(nullable=false)
  23.      */
  24.     private $user;
  25.     /**
  26.      * @ORM\Column(type="string", length=100, nullable=true)
  27.      */
  28.     private $nom;
  29.     /**
  30.      * @ORM\Column(type="string", length=255)
  31.      */
  32.     private $path;
  33.     /**
  34.      * @ORM\Column(type="string", length=25)
  35.      */
  36.     private $type;
  37.     /**
  38.      * @ORM\Column(type="integer", nullable=true)
  39.      */
  40.     private $size;
  41.     /**
  42.      * @ORM\Column(type="string", length=25)
  43.      */
  44.     private $doc;
  45.     /**
  46.     * @ORM\Column(type="datetime")
  47.     * @Gedmo\Timestampable(on="create")
  48.     */
  49.     private $createdAt;
  50.     /**
  51.      * @ORM\Column(type="datetime")
  52.      * @Gedmo\Timestampable(on="update")
  53.      */
  54.     private $updatedAt;
  55.     public function getId(): ?int
  56.     {
  57.         return $this->id;
  58.     }
  59.     public function getUser(): ?User
  60.     {
  61.         return $this->user;
  62.     }
  63.     public function setUser(?User $user): self
  64.     {
  65.         $this->user $user;
  66.         return $this;
  67.     }
  68.     public function getNom(): ?string
  69.     {
  70.         return $this->nom;
  71.     }
  72.     public function setNom(string $nom): self
  73.     {
  74.         $this->nom $nom;
  75.         return $this;
  76.     }
  77.     public function getPath(): ?string
  78.     {
  79.         return $this->path;
  80.     }
  81.     public function setPath(string $path): self
  82.     {
  83.         $this->path $path;
  84.         return $this;
  85.     }
  86.     public function getType(): ?string
  87.     {
  88.         return $this->type;
  89.     }
  90.     public function setType(string $type): self
  91.     {
  92.         $this->type $type;
  93.         return $this;
  94.     }
  95.     public static function isDocTxt($doc){
  96.         return in_array($doc, static::$doc_values_txt);
  97.     }
  98.     
  99.     public static function isDocFile($doc){
  100.         return !in_array($doc, static::$doc_values_txt);
  101.     }
  102.     public function isTxt(): ?string
  103.     {
  104.         return static::isDocTxt($this->doc);
  105.     }
  106.     public function isFile(): ?string
  107.     {
  108.         return static::isDocFile($this->doc);
  109.     }
  110.     public function getSize(): ?int
  111.     {
  112.         return $this->size;
  113.     }
  114.     public function setSize(int $size): self
  115.     {
  116.         $this->size $size;
  117.         return $this;
  118.     }
  119.     public function getContenu(): ?string
  120.     {
  121.         if($this->isTxt())
  122.             return $this->getPath();
  123.         return null;
  124.     }
  125.     public function setContenu(string $contenu): self
  126.     {
  127.         if($this->isTxt())
  128.             $this->setPath($contenu);
  129.         return $this;
  130.     }
  131.     public function getDoc(): ?string
  132.     {
  133.         return $this->doc;
  134.     }
  135.     public function setDoc(string $doc): self
  136.     {
  137.         $this->doc $doc;
  138.         return $this;
  139.     }
  140.     public function getCreatedAt(): ?\DateTimeInterface {
  141.         return $this->createdAt;
  142.     }
  143.     public function setCreatedAt(?\DateTimeInterface $createdAt): self {
  144.         $this->createdAt $createdAt;
  145.                                                                      
  146.         return $this;
  147.     }
  148.     public function getUpdatedAt(): ?\DateTimeInterface {
  149.         return $this->updatedAt;
  150.     }
  151.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self {
  152.         $this->updatedAt $updatedAt;
  153.                                                                      
  154.         return $this;
  155.     }
  156.     public function getDir(?UserEnseignantAccountVehicule $vehicule=null): ?string
  157.     {
  158.         if($vehicule)
  159.         return $vehicule->getDir().'/';
  160.         return $this->getUser()->getDir() .'/documents/';
  161.     }
  162.     public function getRealPath(?UserEnseignantAccountVehicule $vehicule=null): ?string
  163.     {
  164.         return $this->getDir($vehicule) . $this->getPath();
  165.     }
  166. }