<?php
namespace App\Entity;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* Document
*
* @ORM\Table(name="rec_document")
* @ORM\Entity(repositoryClass="App\Repository\RecDocumentRepository")
*
*/
class RecDocument
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @Assert\File( maxSize="10M", mimeTypes={"application/pdf", "image/png"} )
*/
public $file;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255)
*/
private $name;
/**
* @var string
*
* @ORM\Column(name="hiddenName", type="string", length=255)
*/
private $hiddenName;
/**
* @ORM\ManyToOne(targetEntity="RecCandidature", inversedBy="document")
* @ORM\JoinColumn(name="candidature_id", referencedColumnName="id")
*/
protected $candidature;
/**
* @ORM\Column(name="validate", type="boolean")
*/
protected $validate;
/**
* @ORM\Column(name="checked", type="boolean", nullable=true)
*/
protected $checked;
/**
* @ORM\Column(name="ordre", type="integer", nullable=true)
*/
protected $ordre;
/**
* @var \DateTime
* @ORM\Column(name="date_init", type="datetime", nullable=true)
*/
protected $dateInit;
public function __construct()
{
$this->validate = false;
$this->dateInit = new \DateTime('now');
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set name
*
* @param string $name
* @return RecDocument
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set path
*
* @param string $path
* @return RecDocument
*/
public function setHiddenName($hidden)
{
$this->hiddenName = $hidden;
return $this;
}
/**
* Get path
*
* @return string
*/
public function getHiddenName()
{
return $this->hiddenName;
}
public function getAbsolutePath()
{
return $this->getUploadRootDir();
}
public function getWebPath()
{
return "/".$this->getUploadDir().'/'.$this->hiddenName;
}
protected function getUploadRootDir()
{
return __DIR__.'/../../data/'.$this->getUploadDir();
}
public function getUploadDir()
{
return 'files';
}
public function getThumbnail()
{
return ;
}
public function remove()
{
echo $this->getId();die;
}
public function removeFile()
{
if(file_exists($this->getUploadRootDir().'/'.$this->hiddenName))
unlink($this->getUploadRootDir().'/'.$this->hiddenName);
}
/**
* Set candidature
*
* @param \App\Entity\RecCandidature $candidature
* @return RecDocument
*/
public function setCandidature(\App\Entity\RecCandidature $candidature = null)
{
$this->candidature = $candidature;
return $this;
}
/**
* Get candidature
*
* @return \Dosi\RecrutementBundle\Entity\RecCandidature
*/
public function getCandidature()
{
return $this->candidature;
}
/**
* Set validate
*
* @param boolean $validate
* @return RecDocument
*/
public function setValidate($validate)
{
$this->validate = $validate;
return $this;
}
/**
* Get validate
*
* @return boolean
*/
public function getValidate()
{
return $this->validate;
}
/**
* Set checked
*
* @param boolean $checked
* @return RecDocument
*/
public function setChecked($checked)
{
$this->checked = $checked;
return $this;
}
/**
* Get checked
*
* @return boolean
*/
public function getChecked()
{
return $this->checked;
}
public function isValidate(): ?bool
{
return $this->validate;
}
public function isChecked(): ?bool
{
return $this->checked;
}
public function getDateInit(): ?\DateTimeInterface
{
return $this->dateInit;
}
public function setDateInit(?\DateTimeInterface $dateInit): static
{
$this->dateInit = $dateInit;
return $this;
}
public function getOrdre(): ?int
{
return $this->ordre;
}
public function setOrdre(?int $ordre): static
{
$this->ordre = $ordre;
return $this;
}
}