<?php
namespace App\Entity\Clients;
use DateTime;
use Doctrine\ORM\Mapping as ORM;
/**
* Image
*
* @ORM\Table("client__document")
* @ORM\Entity(repositoryClass="App\Repository\Clients\DocumentRepository")
*/
class Document
{
/**
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Clients\Client",inversedBy="documents")
* @ORM\JoinColumn(nullable=false)
*/
private $client;
/**
* @ORM\Column(name="url", type="string", length=255)
*/
private $url;
/**
* @ORM\Column(name="date", type="datetime")
*/
private $date;
public function __construct()
{
$this->date = new Datetime();
}
public function getId(): int
{
return $this->id;
}
public function setUrl(string $url): Document
{
$this->url = $url;
return $this;
}
public function getUrl(): string
{
return $this->url;
}
public function setDate(DateTime $date): Document
{
$this->date = $date;
return $this;
}
public function getDate(): DateTime
{
return $this->date;
}
public function getUploadDir(): string
{
// On retourne le chemin relatif vers l'image pour un navigateur
return 'uploads/clients/documents/'.$this->getClient()->getDate()->format("Y").'/'.$this->getClient()->getDate()->format("m").'/'.$this->getClient()->getDate()->format("d");
//return 'uploads/vehicules/vehicules';
}
protected function getUploadRootDir(): string
{
// On retourne le chemin relatif vers l'image pour notre code PHP
return __DIR__ . '/../../../../web/' . $this->getUploadDir();
}
public function setClient(?Client $client): Document
{
$this->client = $client;
return $this;
}
public function getClient(): ?Client
{
return $this->client;
}
}