<?php
namespace App\Entity;
use App\Repository\UserEnseignantDocumentRepository;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\HttpFoundation\File\UploadedFile;
/**
* @ORM\Entity(repositoryClass=UserEnseignantDocumentRepository::class)
*/
class UserEnseignantDocument
{
static $doc_values = ['cni', 'permis', 'autorisation', 'num_autorisation', 'avis_medical','kbis','rib','vigilance','contrat','rcpro'];
static $doc_values_txt = ['num_autorisation'];
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="userEnseignantDocuments")
* @ORM\JoinColumn(nullable=false)
*/
private $user;
/**
* @ORM\Column(type="string", length=100, nullable=true)
*/
private $nom;
/**
* @ORM\Column(type="string", length=255)
*/
private $path;
/**
* @ORM\Column(type="string", length=25)
*/
private $type;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $size;
/**
* @ORM\Column(type="string", length=25)
*/
private $doc;
/**
* @ORM\Column(type="datetime")
* @Gedmo\Timestampable(on="create")
*/
private $createdAt;
/**
* @ORM\Column(type="datetime")
* @Gedmo\Timestampable(on="update")
*/
private $updatedAt;
public function getId(): ?int
{
return $this->id;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
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 static function isDocTxt($doc){
return in_array($doc, static::$doc_values_txt);
}
public static function isDocFile($doc){
return !in_array($doc, static::$doc_values_txt);
}
public function isTxt(): ?string
{
return static::isDocTxt($this->doc);
}
public function isFile(): ?string
{
return static::isDocFile($this->doc);
}
public function getSize(): ?int
{
return $this->size;
}
public function setSize(int $size): self
{
$this->size = $size;
return $this;
}
public function getContenu(): ?string
{
if($this->isTxt())
return $this->getPath();
return null;
}
public function setContenu(string $contenu): self
{
if($this->isTxt())
$this->setPath($contenu);
return $this;
}
public function getDoc(): ?string
{
return $this->doc;
}
public function setDoc(string $doc): self
{
$this->doc = $doc;
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(?UserEnseignantAccountVehicule $vehicule=null): ?string
{
if($vehicule)
return $vehicule->getDir().'/';
return $this->getUser()->getDir() .'/documents/';
}
public function getRealPath(?UserEnseignantAccountVehicule $vehicule=null): ?string
{
return $this->getDir($vehicule) . $this->getPath();
}
}