src/Entity/UserEnseignantAccountVehicule.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\UserEnseignantAccountVehiculeRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Gedmo\Mapping\Annotation as Gedmo;
  6. /**
  7.  * @ORM\Entity(repositoryClass=UserEnseignantAccountVehiculeRepository::class)
  8.  */
  9. class UserEnseignantAccountVehicule
  10. {
  11.     /**
  12.      * @ORM\Id
  13.      * @ORM\GeneratedValue
  14.      * @ORM\Column(type="integer")
  15.      */
  16.     private $id;
  17.     /**
  18.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="userEnseignantAccountVehicules")
  19.      * @ORM\JoinColumn(nullable=false)
  20.      */
  21.     private $user;
  22.     /**
  23.      * @ORM\Column(type="string", length=255, nullable=true)
  24.      */
  25.     private $vehicule_type;
  26.     /**
  27.      * @ORM\Column(type="string", length=255, nullable=true)
  28.      */
  29.     private $vehicule_marque;
  30.     /**
  31.      * @ORM\Column(type="string", length=255, nullable=true)
  32.      */
  33.     private $vehicule_immatriculation;
  34.     /**
  35.      * @ORM\Column(type="string", length=25, nullable=true)
  36.      */
  37.     private $vehicule_boite;
  38.     /**
  39.      * @ORM\Column(type="string", length=25, nullable=true)
  40.      */
  41.     private $vehicule_carburant;
  42.     /**
  43.     * @ORM\Column(type="datetime")
  44.     * @Gedmo\Timestampable(on="create")
  45.     */
  46.     private $createdAt;
  47.     /**
  48.      * @ORM\Column(type="datetime")
  49.      * @Gedmo\Timestampable(on="update")
  50.      */
  51.     private $updatedAt;
  52.     /**
  53.      * @ORM\OneToOne(targetEntity=UserEnseignantDocument::class, cascade={"persist", "remove"})
  54.      */
  55.     private $vehiculeAssurance;
  56.     /**
  57.      * @ORM\OneToOne(targetEntity=UserEnseignantDocument::class, cascade={"persist", "remove"})
  58.      */
  59.     private $vehiculeControle;
  60.     /**
  61.      * @ORM\Column(type="boolean")
  62.      */
  63.     private $valid=false;
  64.     /**
  65.      * @ORM\Column(type="boolean")
  66.      */
  67.     private $invalid=false;
  68.     /**
  69.      * @ORM\Column(type="datetime", nullable=true)
  70.      */
  71.     private $evaluatedAt;
  72.     public function getId(): ?int
  73.     {
  74.         return $this->id;
  75.     }
  76.     public function getUser(): ?User
  77.     {
  78.         return $this->user;
  79.     }
  80.     public function setUser(?User $user): self
  81.     {
  82.         $this->user $user;
  83.         return $this;
  84.     }
  85.     public function getVehiculeType(): ?string
  86.     {
  87.         return $this->vehicule_type;
  88.     }
  89.     public function setVehiculeType(?string $vehicule_type): self
  90.     {
  91.         $this->vehicule_type $vehicule_type;
  92.         return $this;
  93.     }
  94.     public function getVehiculeMarque(): ?string
  95.     {
  96.         return $this->vehicule_marque;
  97.     }
  98.     public function setVehiculeMarque(?string $vehicule_marque): self
  99.     {
  100.         $this->vehicule_marque $vehicule_marque;
  101.         return $this;
  102.     }
  103.     public function getVehiculeImmatriculation(): ?string
  104.     {
  105.         return $this->vehicule_immatriculation;
  106.     }
  107.     public function setVehiculeImmatriculation(?string $vehicule_immatriculation): self
  108.     {
  109.         $this->vehicule_immatriculation $vehicule_immatriculation;
  110.         return $this;
  111.     }
  112.     public function getVehiculeBoite(): ?string
  113.     {
  114.         return $this->vehicule_boite;
  115.     }
  116.     public function setVehiculeBoite(?string $vehicule_boite): self
  117.     {
  118.         $this->vehicule_boite $vehicule_boite;
  119.         return $this;
  120.     }
  121.     public function getStringBoite(): ?string
  122.     {
  123.         if(!$this->vehicule_boite)
  124.             return null;
  125.         $strings = ['auto'=>'automatique''manu'=>'manuelle'];
  126.         return $strings[$this->vehicule_boite];
  127.     }
  128.     public function getVehiculeCarburant(): ?string
  129.     {
  130.         return $this->vehicule_carburant;
  131.     }
  132.     public function setVehiculeCarburant(?string $vehicule_carburant): self
  133.     {
  134.         $this->vehicule_carburant $vehicule_carburant;
  135.         return $this;
  136.     }
  137.     public function getVehiculeAssurance(): ?UserEnseignantDocument
  138.     {
  139.         return $this->vehiculeAssurance;
  140.     }
  141.     public function setVehiculeAssurance(?UserEnseignantDocument $vehiculeAssurance): self
  142.     {
  143.         $this->vehiculeAssurance $vehiculeAssurance;
  144.         return $this;
  145.     }
  146.     public function getVehiculeControle(): ?UserEnseignantDocument
  147.     {
  148.         return $this->vehiculeControle;
  149.     }
  150.     public function setVehiculeControle(?UserEnseignantDocument $vehiculeControle): self
  151.     {
  152.         $this->vehiculeControle $vehiculeControle;
  153.         return $this;
  154.     }
  155.     public function getValid(): ?bool
  156.     {
  157.         return $this->valid;
  158.     }
  159.     public function getCreatedAt(): ?\DateTimeInterface {
  160.         return $this->createdAt;
  161.     }
  162.     public function setCreatedAt(?\DateTimeInterface $createdAt): self {
  163.         $this->createdAt $createdAt;
  164.                                                                      
  165.         return $this;
  166.     }
  167.     public function getUpdatedAt(): ?\DateTimeInterface {
  168.         return $this->updatedAt;
  169.     }
  170.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self {
  171.         $this->updatedAt $updatedAt;
  172.                                                                         
  173.         return $this;
  174.     }
  175.     public function getInvalid(): ?bool
  176.     {
  177.         return $this->invalid;
  178.     }
  179.     public function setInvalid(bool $invalid): self
  180.     {
  181.         $this->invalid $invalid;
  182.         if ($invalid) {
  183.             $this->setEvaluatedAt(new \DateTime('NOW'));
  184.         }
  185.         return $this;
  186.     }
  187.     
  188.     public function setValid(bool $valid): self
  189.     {
  190.         $this->valid $valid;
  191.         if ($valid) {
  192.             $this->setEvaluatedAt(new \DateTime('NOW'));
  193.         }
  194.         return $this;
  195.     }
  196.     public function getEvaluatedAt(): ?\DateTimeInterface
  197.     {
  198.         return $this->evaluatedAt;
  199.     }
  200.     public function setEvaluatedAt(?\DateTimeInterface $evaluatedAt): self
  201.     {
  202.         $this->evaluatedAt $evaluatedAt;
  203.         return $this;
  204.     }
  205.     public function removeUserEnseignantDocument(UserEnseignantDocument $Document): self
  206.     {
  207.         switch($Document->getDoc()){
  208.             case'assurance':{
  209.                 $this->setVehiculeAssurance(null);
  210.             }break;
  211.             case'controle':{
  212.                 $this->setVehiculeControle(null);
  213.             }break;
  214.         }
  215.         return $this;
  216.     }
  217.     public function addUserEnseignantDocument(UserEnseignantDocument $Document): self
  218.     {
  219.         switch($Document->getDoc()){
  220.             case'assurance':{
  221.                 $Document->setUser($this->getUser());
  222.                 $this->setVehiculeAssurance($Document);
  223.             }break;
  224.             case'controle':{
  225.                 $Document->setUser($this->getUser());
  226.                 $this->setVehiculeControle($Document);
  227.             }break;
  228.         }
  229.         return $this;
  230.     }
  231.     public function getDir(): ?string
  232.     {
  233.         $slugger = new \Symfony\Component\String\Slugger\AsciiSlugger;
  234.         $path $this->getUser()->getDir() .'/';
  235.         $path.= 'vehicules/'.$slugger->slug($this->getVehiculeImmatriculation());
  236.         return $path;
  237.     }
  238. }