<?php
namespace App\Entity;
use App\Repository\UserEnseignantAccountVehiculeRepository;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
/**
* @ORM\Entity(repositoryClass=UserEnseignantAccountVehiculeRepository::class)
*/
class UserEnseignantAccountVehicule
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="userEnseignantAccountVehicules")
* @ORM\JoinColumn(nullable=false)
*/
private $user;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $vehicule_type;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $vehicule_marque;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $vehicule_immatriculation;
/**
* @ORM\Column(type="string", length=25, nullable=true)
*/
private $vehicule_boite;
/**
* @ORM\Column(type="string", length=25, nullable=true)
*/
private $vehicule_carburant;
/**
* @ORM\Column(type="datetime")
* @Gedmo\Timestampable(on="create")
*/
private $createdAt;
/**
* @ORM\Column(type="datetime")
* @Gedmo\Timestampable(on="update")
*/
private $updatedAt;
/**
* @ORM\OneToOne(targetEntity=UserEnseignantDocument::class, cascade={"persist", "remove"})
*/
private $vehiculeAssurance;
/**
* @ORM\OneToOne(targetEntity=UserEnseignantDocument::class, cascade={"persist", "remove"})
*/
private $vehiculeControle;
/**
* @ORM\Column(type="boolean")
*/
private $valid=false;
/**
* @ORM\Column(type="boolean")
*/
private $invalid=false;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $evaluatedAt;
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 getVehiculeType(): ?string
{
return $this->vehicule_type;
}
public function setVehiculeType(?string $vehicule_type): self
{
$this->vehicule_type = $vehicule_type;
return $this;
}
public function getVehiculeMarque(): ?string
{
return $this->vehicule_marque;
}
public function setVehiculeMarque(?string $vehicule_marque): self
{
$this->vehicule_marque = $vehicule_marque;
return $this;
}
public function getVehiculeImmatriculation(): ?string
{
return $this->vehicule_immatriculation;
}
public function setVehiculeImmatriculation(?string $vehicule_immatriculation): self
{
$this->vehicule_immatriculation = $vehicule_immatriculation;
return $this;
}
public function getVehiculeBoite(): ?string
{
return $this->vehicule_boite;
}
public function setVehiculeBoite(?string $vehicule_boite): self
{
$this->vehicule_boite = $vehicule_boite;
return $this;
}
public function getStringBoite(): ?string
{
if(!$this->vehicule_boite)
return null;
$strings = ['auto'=>'automatique', 'manu'=>'manuelle'];
return $strings[$this->vehicule_boite];
}
public function getVehiculeCarburant(): ?string
{
return $this->vehicule_carburant;
}
public function setVehiculeCarburant(?string $vehicule_carburant): self
{
$this->vehicule_carburant = $vehicule_carburant;
return $this;
}
public function getVehiculeAssurance(): ?UserEnseignantDocument
{
return $this->vehiculeAssurance;
}
public function setVehiculeAssurance(?UserEnseignantDocument $vehiculeAssurance): self
{
$this->vehiculeAssurance = $vehiculeAssurance;
return $this;
}
public function getVehiculeControle(): ?UserEnseignantDocument
{
return $this->vehiculeControle;
}
public function setVehiculeControle(?UserEnseignantDocument $vehiculeControle): self
{
$this->vehiculeControle = $vehiculeControle;
return $this;
}
public function getValid(): ?bool
{
return $this->valid;
}
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 getInvalid(): ?bool
{
return $this->invalid;
}
public function setInvalid(bool $invalid): self
{
$this->invalid = $invalid;
if ($invalid) {
$this->setEvaluatedAt(new \DateTime('NOW'));
}
return $this;
}
public function setValid(bool $valid): self
{
$this->valid = $valid;
if ($valid) {
$this->setEvaluatedAt(new \DateTime('NOW'));
}
return $this;
}
public function getEvaluatedAt(): ?\DateTimeInterface
{
return $this->evaluatedAt;
}
public function setEvaluatedAt(?\DateTimeInterface $evaluatedAt): self
{
$this->evaluatedAt = $evaluatedAt;
return $this;
}
public function removeUserEnseignantDocument(UserEnseignantDocument $Document): self
{
switch($Document->getDoc()){
case'assurance':{
$this->setVehiculeAssurance(null);
}break;
case'controle':{
$this->setVehiculeControle(null);
}break;
}
return $this;
}
public function addUserEnseignantDocument(UserEnseignantDocument $Document): self
{
switch($Document->getDoc()){
case'assurance':{
$Document->setUser($this->getUser());
$this->setVehiculeAssurance($Document);
}break;
case'controle':{
$Document->setUser($this->getUser());
$this->setVehiculeControle($Document);
}break;
}
return $this;
}
public function getDir(): ?string
{
$slugger = new \Symfony\Component\String\Slugger\AsciiSlugger;
$path = $this->getUser()->getDir() .'/';
$path.= 'vehicules/'.$slugger->slug($this->getVehiculeImmatriculation());
return $path;
}
}