src/Entity/Clients/Document.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Clients;
  3. use DateTime;
  4. use Doctrine\ORM\Mapping as ORM;
  5. /**
  6.  * Image
  7.  *
  8.  * @ORM\Table("client__document")
  9.  * @ORM\Entity(repositoryClass="App\Repository\Clients\DocumentRepository")
  10.  */
  11. class Document
  12. {
  13.     /**
  14.      * @ORM\Column(name="id", type="integer")
  15.      * @ORM\Id
  16.      * @ORM\GeneratedValue(strategy="AUTO")
  17.      */
  18.     private $id;
  19.     /**
  20.      * @ORM\ManyToOne(targetEntity="App\Entity\Clients\Client",inversedBy="documents")
  21.      * @ORM\JoinColumn(nullable=false)
  22.      */
  23.     private $client;
  24.     
  25.     /**
  26.      * @ORM\Column(name="url", type="string", length=255)
  27.      */
  28.     private $url;
  29.     /**
  30.      * @ORM\Column(name="date", type="datetime")
  31.      */
  32.     private $date;
  33.     public function __construct()
  34.     {
  35.         $this->date = new Datetime();
  36.     }
  37.     public function getId(): int
  38.     {
  39.         return $this->id;
  40.     }
  41.     public function setUrl(string $url): Document
  42.     {
  43.         $this->url $url;
  44.         return $this;
  45.     }
  46.     public function getUrl(): string
  47.     {
  48.         return $this->url;
  49.     }
  50.     public function setDate(DateTime $date): Document
  51.     {
  52.         $this->date $date;
  53.         return $this;
  54.     }
  55.     public function getDate(): DateTime
  56.     {
  57.         return $this->date;
  58.     }
  59.     
  60.     public function getUploadDir(): string
  61.     {
  62.         // On retourne le chemin relatif vers l'image pour un navigateur
  63.         return 'uploads/clients/documents/'.$this->getClient()->getDate()->format("Y").'/'.$this->getClient()->getDate()->format("m").'/'.$this->getClient()->getDate()->format("d");
  64.         //return 'uploads/vehicules/vehicules';
  65.     }
  66.     protected function getUploadRootDir(): string
  67.     {
  68.         // On retourne le chemin relatif vers l'image pour notre code PHP
  69.         return __DIR__ '/../../../../web/' $this->getUploadDir();
  70.     }
  71.     public function setClient(?Client $client): Document
  72.     {
  73.         $this->client $client;
  74.         return $this;
  75.     }
  76.     public function getClient(): ?Client
  77.     {
  78.         return $this->client;
  79.     }
  80. }