src/Entity/Conductor.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ConductorRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. use Symfony\Component\HttpFoundation\File\File;
  9. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  10. /**
  11.  * @ORM\Entity(repositoryClass=ConductorRepository::class)
  12.  * @Vich\Uploadable
  13.  */
  14. class Conductor
  15. {
  16.     /**
  17.      * @ORM\Id
  18.      * @ORM\GeneratedValue
  19.      * @ORM\Column(type="integer")
  20.      */
  21.     private $id;
  22.     /**
  23.      * @ORM\Column(type="string", length=255)
  24.      */
  25.     private $nombre;
  26.     /**
  27.      * @ORM\Column(type="string", length=255)
  28.      */
  29.     private $rut;
  30.     /**
  31.      * @ORM\Column(type="string", length=255, nullable=true)
  32.      */
  33.     private $telefono;
  34.     /**
  35.      * @ORM\Column(type="boolean")
  36.      */
  37.     private $activo;
  38.     /**
  39.      * @ORM\ManyToMany(targetEntity=LicenciaConducir::class)
  40.      */
  41.     private $licenciaConducir;
  42.     /**
  43.      * @ORM\Column(type="date", nullable=true)
  44.      */
  45.     private $fechaVencimientoLicencia;
  46.     /**
  47.      * @ORM\OneToMany(targetEntity=Ruta::class, mappedBy="conductor")
  48.      */
  49.     private $rutas;
  50.     /**
  51.      * @ORM\Column(type="datetime", nullable=true)
  52.      */
  53.     private $fechaActualizacion;
  54.     /**
  55.      * @ORM\Column(type="string", length=255, nullable=true)
  56.      */
  57.     private $documentoName;
  58.     /**
  59.      * NOTE: This is not a mapped field of entity metadata, just a simple property.
  60.      * @Assert\File(
  61.      *     maxSize = "200Mi",
  62.      *     mimeTypes={ "image/*" }
  63.      * )
  64.      * @Vich\UploadableField(mapping="conductores_foto", fileNameProperty="documentoName")
  65.      * @var File
  66.      */
  67.     private $documentoFile;
  68.     /**
  69.      * @ORM\OneToMany(targetEntity=Vehiculo::class, mappedBy="conductor")
  70.      */
  71.     private $vehiculos;
  72.     /**
  73.      * @ORM\Column(type="text", nullable=true)
  74.      */
  75.     private $observaciones;
  76.     /**
  77.      * @ORM\OneToMany(targetEntity=DocumentoConductor::class, mappedBy="conductor")
  78.      */
  79.     private $documentoConductors;
  80.     /**
  81.      * @ORM\Column(type="integer", nullable=true)
  82.      */
  83.     private $telefonoContactoAnexo;
  84.     /**
  85.      * @ORM\Column(type="string", length=255, nullable=true)
  86.      */
  87.     private $contactoEmergencia;
  88.     /**
  89.      * @ORM\Column(type="boolean", nullable=true)
  90.      */
  91.     private $examenFisico;
  92.     /**
  93.      * @ORM\Column(type="datetime", nullable=true)
  94.      */
  95.     private $examenFisicoVencimiento;
  96.     /**
  97.      * @ORM\Column(type="boolean", nullable=true)
  98.      */
  99.     private $testDrogas;
  100.     /**
  101.      * @ORM\Column(type="datetime", nullable=true)
  102.      */
  103.     private $testDrogasVencimiento;
  104.     /**
  105.      * @ORM\Column(type="datetime", nullable=true)
  106.      */
  107.     private $fechaNotificacionLicencia;
  108.     /**
  109.      * @ORM\Column(type="datetime", nullable=true)
  110.      */
  111.     private $fechaNotificacionExamenFisico;
  112.     /**
  113.      * @ORM\Column(type="datetime", nullable=true)
  114.      */
  115.     private $fechaNotificacionTestDrogas;
  116.     public function getDocumentoNameOriginal()
  117.     {
  118.         $docName $this->getDocumentoName();
  119.         if($docName)
  120.         {
  121.             $posName strrpos($docName'-');
  122.             $posExt strrpos($docName'.');
  123.             if($posName && $posExt)
  124.             {
  125.                 $name substr($docName0$posName);
  126.                 $ext substr($docName$posExt);
  127.                 return $name.$ext;
  128.             }
  129.         }
  130.         return $docName;
  131.     }
  132.     
  133.     /**
  134.      * If manually uploading a file (i.e. not using Symfony Form) ensure an instance
  135.      * of 'UploadedFile' is injected into this setter to trigger the  update. If this
  136.      * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
  137.      * must be able to accept an instance of 'File' as the bundle will inject one here
  138.      * during Doctrine hydration.
  139.      *
  140.      * @param File|\Symfony\Component\HttpFoundation\File\UploadedFile $documento
  141.      *
  142.      * @return Product
  143.      */
  144.     public function setDocumentoFile(?File $documento null): void
  145.     {
  146.         $this->documentoFile $documento;
  147.         if ($documento) {
  148.             // It is required that at least one field changes if you are using doctrine
  149.             // otherwise the event listeners won't be called and the file is lost
  150.             $this->fechaActualizacion = new \DateTimeImmutable(null);
  151.         }
  152.     }
  153.     /**
  154.      * @return File|null
  155.      */
  156.     public function getDocumentoFile(): ?File
  157.     {
  158.         return $this->documentoFile;
  159.     }
  160.     public function getDocumentoName(): ?string
  161.     {
  162.         return $this->documentoName;
  163.     }
  164.     public function setDocumentoName(?string $documentoName ""): self
  165.     {
  166.         $this->documentoName $documentoName;
  167.         return $this;
  168.     }
  169.     public function __construct()
  170.     {
  171.         $this->licenciaConducir = new ArrayCollection();
  172.         $this->rutas = new ArrayCollection();
  173.         $this->vehiculos = new ArrayCollection();
  174.         $this->documentoConductors = new ArrayCollection();
  175.     }
  176.     public function __toString() 
  177.     {
  178.         return $this->nombre;
  179.     }
  180.     public function getId(): ?int
  181.     {
  182.         return $this->id;
  183.     }
  184.     public function getNombre(): ?string
  185.     {
  186.         return $this->nombre;
  187.     }
  188.     public function setNombre(string $nombre): self
  189.     {
  190.         $this->nombre $nombre;
  191.         return $this;
  192.     }
  193.     public function getRut(): ?string
  194.     {
  195.         return $this->rut;
  196.     }
  197.     public function setRut(string $rut): self
  198.     {
  199.         $this->rut $rut;
  200.         return $this;
  201.     }
  202.     public function getTelefono(): ?string
  203.     {
  204.         return $this->telefono;
  205.     }
  206.     public function setTelefono(?string $telefono): self
  207.     {
  208.         $this->telefono $telefono;
  209.         return $this;
  210.     }
  211.     public function getActivo(): ?bool
  212.     {
  213.         return $this->activo;
  214.     }
  215.     public function setActivo(bool $activo): self
  216.     {
  217.         $this->activo $activo;
  218.         return $this;
  219.     }
  220.     /**
  221.      * @return Collection|LicenciaConducir[]
  222.      */
  223.     public function getLicenciaConducir(): Collection
  224.     {
  225.         return $this->licenciaConducir;
  226.     }
  227.     public function addLicenciaConducir(LicenciaConducir $licenciaConducir): self
  228.     {
  229.         if (!$this->licenciaConducir->contains($licenciaConducir)) {
  230.             $this->licenciaConducir[] = $licenciaConducir;
  231.         }
  232.         return $this;
  233.     }
  234.     public function removeLicenciaConducir(LicenciaConducir $licenciaConducir): self
  235.     {
  236.         if ($this->licenciaConducir->contains($licenciaConducir)) {
  237.             $this->licenciaConducir->removeElement($licenciaConducir);
  238.         }
  239.         return $this;
  240.     }
  241.     public function getFechaVencimientoLicencia(): ?\DateTimeInterface
  242.     {
  243.         return $this->fechaVencimientoLicencia;
  244.     }
  245.     public function setFechaVencimientoLicencia(?\DateTimeInterface $fechaVencimientoLicencia): self
  246.     {
  247.         $this->fechaVencimientoLicencia $fechaVencimientoLicencia;
  248.         return $this;
  249.     }
  250.     /**
  251.      * @return Collection|Ruta[]
  252.      */
  253.     public function getRutas(): Collection
  254.     {
  255.         return $this->rutas;
  256.     }
  257.     public function addRuta(Ruta $ruta): self
  258.     {
  259.         if (!$this->rutas->contains($ruta)) {
  260.             $this->rutas[] = $ruta;
  261.             $ruta->setConductor($this);
  262.         }
  263.         return $this;
  264.     }
  265.     public function removeRuta(Ruta $ruta): self
  266.     {
  267.         if ($this->rutas->contains($ruta)) {
  268.             $this->rutas->removeElement($ruta);
  269.             // set the owning side to null (unless already changed)
  270.             if ($ruta->getConductor() === $this) {
  271.                 $ruta->setConductor(null);
  272.             }
  273.         }
  274.         return $this;
  275.     }
  276.     public function getVehiculo(): ?Vehiculo
  277.     {
  278.         return $this->vehiculo;
  279.     }
  280.     public function setVehiculo(?Vehiculo $vehiculo): self
  281.     {
  282.         $this->vehiculo $vehiculo;
  283.         // set (or unset) the owning side of the relation if necessary
  284.         $newConductor null === $vehiculo null $this;
  285.         if ($vehiculo->getConductor() !== $newConductor) {
  286.             $vehiculo->setConductor($newConductor);
  287.         }
  288.         return $this;
  289.     }
  290.     /**
  291.      * @return Collection|Vehiculo[]
  292.      */
  293.     public function getVehiculos(): Collection
  294.     {
  295.         return $this->vehiculos;
  296.     }
  297.     public function addVehiculo(Vehiculo $vehiculo): self
  298.     {
  299.         if (!$this->vehiculos->contains($vehiculo)) {
  300.             $this->vehiculos[] = $vehiculo;
  301.             $vehiculo->setConductor($this);
  302.         }
  303.         return $this;
  304.     }
  305.     public function removeVehiculo(Vehiculo $vehiculo): self
  306.     {
  307.         if ($this->vehiculos->contains($vehiculo)) {
  308.             $this->vehiculos->removeElement($vehiculo);
  309.             // set the owning side to null (unless already changed)
  310.             if ($vehiculo->getConductor() === $this) {
  311.                 $vehiculo->setConductor(null);
  312.             }
  313.         }
  314.         return $this;
  315.     }
  316.     public function getObservaciones(): ?string
  317.     {
  318.         return $this->observaciones;
  319.     }
  320.     public function setObservaciones(?string $observaciones): self
  321.     {
  322.         $this->observaciones $observaciones;
  323.         return $this;
  324.     }
  325.     /**
  326.      * @return Collection|DocumentoConductor[]
  327.      */
  328.     public function getDocumentoConductors(): Collection
  329.     {
  330.         return $this->documentoConductors;
  331.     }
  332.     public function addDocumentoConductor(DocumentoConductor $documentoConductor): self
  333.     {
  334.         if (!$this->documentoConductors->contains($documentoConductor)) {
  335.             $this->documentoConductors[] = $documentoConductor;
  336.             $documentoConductor->setConductor($this);
  337.         }
  338.         return $this;
  339.     }
  340.     public function removeDocumentoConductor(DocumentoConductor $documentoConductor): self
  341.     {
  342.         if ($this->documentoConductors->contains($documentoConductor)) {
  343.             $this->documentoConductors->removeElement($documentoConductor);
  344.             // set the owning side to null (unless already changed)
  345.             if ($documentoConductor->getConductor() === $this) {
  346.                 $documentoConductor->setConductor(null);
  347.             }
  348.         }
  349.         return $this;
  350.     }
  351.     public function getTelefonoContactoAnexo(): ?int
  352.     {
  353.         return $this->telefonoContactoAnexo;
  354.     }
  355.     public function setTelefonoContactoAnexo(?int $telefonoContactoAnexo): self
  356.     {
  357.         $this->telefonoContactoAnexo $telefonoContactoAnexo;
  358.         return $this;
  359.     }
  360.     public function getContactoEmergencia(): ?string
  361.     {
  362.         return $this->contactoEmergencia;
  363.     }
  364.     public function setContactoEmergencia(?string $contactoEmergencia): self
  365.     {
  366.         $this->contactoEmergencia $contactoEmergencia;
  367.         return $this;
  368.     }
  369.     public function getExamenFisico(): ?bool
  370.     {
  371.         return $this->examenFisico;
  372.     }
  373.     public function setExamenFisico(?bool $examenFisico): self
  374.     {
  375.         $this->examenFisico $examenFisico;
  376.         return $this;
  377.     }
  378.     public function getExamenFisicoVencimiento(): ?\DateTimeInterface
  379.     {
  380.         return $this->examenFisicoVencimiento;
  381.     }
  382.     public function setExamenFisicoVencimiento(?\DateTimeInterface $examenFisicoVencimiento): self
  383.     {
  384.         $this->examenFisicoVencimiento $examenFisicoVencimiento;
  385.         return $this;
  386.     }
  387.     public function getTestDrogas(): ?bool
  388.     {
  389.         return $this->testDrogas;
  390.     }
  391.     public function setTestDrogas(?bool $testDrogas): self
  392.     {
  393.         $this->testDrogas $testDrogas;
  394.         return $this;
  395.     }
  396.     public function getTestDrogasVencimiento(): ?\DateTimeInterface
  397.     {
  398.         return $this->testDrogasVencimiento;
  399.     }
  400.     public function setTestDrogasVencimiento(?\DateTimeInterface $testDrogasVencimiento): self
  401.     {
  402.         $this->testDrogasVencimiento $testDrogasVencimiento;
  403.         return $this;
  404.     }
  405.     public function getFechaNotificacionLicencia(): ?\DateTimeInterface
  406.     {
  407.         return $this->fechaNotificacionLicencia;
  408.     }
  409.     public function setFechaNotificacionLicencia(?\DateTimeInterface $fechaNotificacionLicencia): self
  410.     {
  411.         $this->fechaNotificacionLicencia $fechaNotificacionLicencia;
  412.         return $this;
  413.     }
  414.     public function getFechaNotificacionExamenFisico(): ?\DateTimeInterface
  415.     {
  416.         return $this->fechaNotificacionExamenFisico;
  417.     }
  418.     public function setFechaNotificacionExamenFisico(?\DateTimeInterface $fechaNotificacionExamenFisico): self
  419.     {
  420.         $this->fechaNotificacionExamenFisico $fechaNotificacionExamenFisico;
  421.         return $this;
  422.     }
  423.     public function getFechaNotificacionTestDrogas(): ?\DateTimeInterface
  424.     {
  425.         return $this->fechaNotificacionTestDrogas;
  426.     }
  427.     public function setFechaNotificacionTestDrogas(?\DateTimeInterface $fechaNotificacionTestDrogas): self
  428.     {
  429.         $this->fechaNotificacionTestDrogas $fechaNotificacionTestDrogas;
  430.         return $this;
  431.     }
  432.    
  433. }