<?php
namespace App\Entity;
use App\Repository\LivretEstimationRepository;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
/**
* @ORM\Entity(repositoryClass=LivretEstimationRepository::class)
* @ORM\HasLifecycleCallbacks
*/
class LivretEstimation
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="integer")
*/
private $heures;
/**
* @ORM\Column(type="text")
*/
private $commentaire;
/**
* @ORM\ManyToOne(targetEntity=Livret::class, inversedBy="estimations")
* @ORM\JoinColumn(nullable=false)
*/
private $livret;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="estimations")
* @ORM\JoinColumn(nullable=false)
*/
private $eleve;
/**
* @ORM\Column(type="date")
* @Gedmo\Timestampable(on="create")
*/
private $created;
/**
* @ORM\Column(type="date")
* @Gedmo\Timestampable(on="update")
*/
private $updated;
/**
* @ORM\Column(type="date",nullable=true)
*/
private $dateInscription;
/**
* @ORM\Column(type="text",nullable=true)
*/
private $sousCategoriePermis;
public static $sousCategoriesPermis = [ 'A', 'A1', 'A2', 'B', 'BE', 'B1', 'C', 'CE', 'C1', 'C1E', 'D', 'DE', 'D1', 'D1E' ];
/**
* @ORM\Column(type="text",nullable=true)
*/
private $typeVehicule;
public static $typesVehicules = ['MANUEL', 'AUTOMATIQUE'];
/**
* @ORM\Column(type="text",nullable=true)
*/
private $typeFormation;
public static $typesFormations = ['AAC', 'TRADITIONNELLE', 'SUPERVISEE', 'ENCADREE'];
public function getId(): ?int
{
return $this->id;
}
public function getHeures(): ?int
{
return $this->heures;
}
public function setHeures(int $heures): self
{
$this->heures = $heures;
return $this;
}
public function getCommentaire(): ?string
{
return $this->commentaire;
}
public function setCommentaire(string $commentaire): self
{
$this->commentaire = $commentaire;
return $this;
}
public function getLivret(): ?Livret
{
return $this->livret;
}
public function setLivret(?Livret $livret): self
{
$this->livret = $livret;
return $this;
}
public function getEleve(): ?User
{
return $this->eleve;
}
public function setEleve(?User $eleve): self
{
$this->eleve = $eleve;
return $this;
}
public function getCreated(): ?\DateTimeInterface
{
return $this->created;
}
public function setCreated(\DateTimeInterface $created): self
{
$this->created = $created;
return $this;
}
/**
* @ORM\PrePersist
*/
public function makeCreated()
{
$this->created = $this->dateInscription = new \DateTimeImmutable();
}
public function getUpdated(): ?\DateTimeInterface
{
return $this->updated;
}
public function setUpdated(\DateTimeInterface $updated): self
{
$this->updated = $updated;
return $this;
}
public function getDateInscription(): ?\DateTimeInterface
{
return $this->dateInscription;
}
public function setDateInscription(\DateTimeInterface $inscription): self
{
$this->dateInscription = $inscription;
return $this;
}
/**
* @ORM\PrePersist
* @ORM\PreUpdate
*/
public function makeUpdated()
{
$this->updated = new \DateTimeImmutable();
}
public function getSousCategoriePermis(): ?string
{
return $this->sousCategoriePermis;
}
public function setSousCategoriePermis(?string $sousCategoriePermis): self
{
$this->sousCategoriePermis = $sousCategoriePermis;
return $this;
}
/**
* @ORM\PrePersist
* @ORM\PreUpdate
*/
public function testSousCategoriePermis()
{
if(empty($this->sousCategoriePermis)) return;
if (!in_array($this->sousCategoriePermis, self::$sousCategoriesPermis)) {
throw new \UnexpectedValueException('sousCategoriePermis ('.$this->sousCategoriePermis.') expects one of: ' . implode(', ', self::$sousCategoriesPermis));
}
}
public function getTypeVehicule(): ?string
{
return $this->typeVehicule;
}
public function setTypeVehicule(?string $typeVehicule): self
{
$this->typeVehicule = $typeVehicule;
return $this;
}
/**
* @ORM\PrePersist
* @ORM\PreUpdate
*/
public function testTypeVehicule()
{
if(empty($this->typeVehicule)) return;
if (!in_array($this->typeVehicule, self::$typesVehicules)) {
throw new \UnexpectedValueException('typeVehicule ('.$this->typeVehicule.') expects one of: ' . implode(', ', self::$typesVehicules));
}
}
public function getTypeFormation(): ?string
{
return $this->typeFormation;
}
public function setTypeFormation(?string $typeFormation): self
{
$this->typeFormation = $typeFormation;
return $this;
}
/**
* @ORM\PrePersist
* @ORM\PreUpdate
*/
public function testTypeFormation()
{
if(empty($this->typeFormation)) return;
if (!in_array($this->typeFormation, self::$typesFormations)) {
throw new \UnexpectedValueException('typeFormation ('.$this->typeFormation.') expects one of: ' . implode(', ', self::$typesFormations));
}
}
}