src/Entity/SsoPersona.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\SsoPersonaRepository;
  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\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  9. /**
  10.  * @ORM\Entity(repositoryClass=SsoPersonaRepository::class)
  11.  * @UniqueEntity("dni", message="DNI ya registrado en el sistema.")
  12.  * @UniqueEntity("email_personal", message="Email ya registrado en el sistema.")
  13.  * @UniqueEntity("dni_tramite", message="Nro de trámite del DNI ya registrado en el sistema.")
  14.  */
  15. class SsoPersona
  16. {
  17.     const GENEROS = ['F''M''O'];
  18.     /**
  19.      * @ORM\Id
  20.      * @ORM\GeneratedValue
  21.      * @ORM\Column(type="integer")
  22.      */
  23.     private $id;
  24.     /**
  25.      * @ORM\Column(type="string", length=150)
  26.      * @Assert\NotBlank(
  27.      *     message = "Campo requerido."
  28.      * )
  29.      * @Assert\Length(
  30.      *      min = 3,
  31.      *      max = 150,
  32.      *      minMessage = "Tamaño mínimo {{ limit }}",
  33.      *      maxMessage = "Tamaño máximo {{ limit }}"
  34.      * )
  35.      */
  36.     private $nombres;
  37.     /**
  38.      * @ORM\Column(type="string", length=150)
  39.      * @Assert\NotBlank(
  40.      *     message = "Campo requerido."
  41.      * )
  42.      * @Assert\Length(
  43.      *      min = 3,
  44.      *      max = 150,
  45.      *      minMessage = "Tamaño mínimo {{ limit }}",
  46.      *      maxMessage = "Tamaño máximo {{ limit }}"
  47.      * )
  48.      */
  49.     private $apellidos;
  50.     /**
  51.      * @ORM\Column(type="integer", unique=true)
  52.      * @Assert\NotBlank(
  53.      *     message = "Campo requerido."
  54.      * )
  55.      * @Assert\Range(
  56.      *      min = 1000000,
  57.      *      max = 100000000,
  58.      *      notInRangeMessage = "Número entre {{ min }} y {{ max }}",
  59.      *      invalidMessage = "Número inválido"
  60.      * )
  61.      */
  62.     private $dni;
  63.     /**
  64.      * @ORM\Column(type="string", length=255, nullable=true)
  65.      */
  66.     private $urlDni;
  67.     /**
  68.      * @ORM\Column(type="string", length=100, nullable=true, unique=true)
  69.      * @Assert\Email(
  70.      *     message = "El Email es incorrecto.",
  71.      *     mode= "strict"
  72.      * )
  73.      */
  74.     private $email_personal;
  75.     /**
  76.      * @ORM\OneToMany(targetEntity=SsoUser::class, mappedBy="persona", cascade={"all"})
  77.      * @Assert\Valid
  78.      */
  79.     private $usuariosPortal;
  80.     /**
  81.      * @ORM\Column(type="string", length=20, nullable=true, unique=true)
  82.      * @Assert\NotBlank(
  83.      *     message = "Campo requerido."
  84.      * )
  85.      */
  86.     private $dni_tramite;
  87.     /**
  88.      * @ORM\Column(type="string", length=2, nullable=true)
  89.      * @Assert\Choice(choices=SsoPersona::GENEROS, message="Género inválido.")
  90.      */
  91.     private $genero;
  92.     /**
  93.      * @ORM\OneToMany(targetEntity=SsoMatricula::class, mappedBy="persona", cascade={"all"}, orphanRemoval=true)
  94.      * @Assert\Valid
  95.      */
  96.     private $matriculas;
  97.     /**
  98.      * @ORM\OneToMany(targetEntity=SsoFirmaPersona::class, mappedBy="persona", cascade={"all"}, orphanRemoval=true)
  99.      */
  100.     private $firmasPersona;
  101.     public function __construct()
  102.     {
  103.         $this->usuariosPortal = new ArrayCollection();
  104.         $this->matriculas = new ArrayCollection();
  105.         $this->firmasPersona = new ArrayCollection();
  106.     }
  107.     public function getId(): ?int
  108.     {
  109.         return $this->id;
  110.     }
  111.     public function getNombres(): ?string
  112.     {
  113.         return $this->nombres;
  114.     }
  115.     public function setNombres(string $nombres): self
  116.     {
  117.         $this->nombres $nombres;
  118.         return $this;
  119.     }
  120.     public function getApellidos(): ?string
  121.     {
  122.         return $this->apellidos;
  123.     }
  124.     public function setApellidos(string $apellidos): self
  125.     {
  126.         $this->apellidos $apellidos;
  127.         return $this;
  128.     }
  129.     public function getDni(): ?int
  130.     {
  131.         return $this->dni;
  132.     }
  133.     public function setDni(int $dni): self
  134.     {
  135.         $this->dni $dni;
  136.         return $this;
  137.     }
  138.     public function getEmailPersonal(): ?string
  139.     {
  140.         return $this->email_personal;
  141.     }
  142.     public function setEmailPersonal(?string $email_personal): self
  143.     {
  144.         $this->email_personal $email_personal;
  145.         return $this;
  146.     }
  147.     /**
  148.      * @return Collection|SsoUser[]
  149.      */
  150.     public function getUsuariosPortal(): Collection
  151.     {
  152.         return $this->usuariosPortal;
  153.     }
  154.     public function addUsuariosPortal(SsoUser $usuariosPortal): self
  155.     {
  156.         if (!$this->usuariosPortal->contains($usuariosPortal)) {
  157.             $this->usuariosPortal[] = $usuariosPortal;
  158.             $usuariosPortal->setPersona($this);
  159.         }
  160.         return $this;
  161.     }
  162.     public function removeUsuariosPortal(SsoUser $usuariosPortal): self
  163.     {
  164.         if ($this->usuariosPortal->removeElement($usuariosPortal)) {
  165.             // set the owning side to null (unless already changed)
  166.             if ($usuariosPortal->getPersona() === $this) {
  167.                 $usuariosPortal->setPersona(null);
  168.             }
  169.         }
  170.         return $this;
  171.     }
  172.     public function getDniTramite(): ?string
  173.     {
  174.         return $this->dni_tramite;
  175.     }
  176.     public function setDniTramite(string $dni_tramite): self
  177.     {
  178.         $this->dni_tramite $dni_tramite;
  179.         return $this;
  180.     }
  181.     public function getGenero(): ?string
  182.     {
  183.         return $this->genero;
  184.     }
  185.     public function setGenero(?string $genero): self
  186.     {
  187.         $this->genero $genero;
  188.         return $this;
  189.     }
  190.     /**
  191.      * @return Collection|SsoMatricula[]
  192.      */
  193.     public function getMatriculas(): Collection
  194.     {
  195.         return $this->matriculas;
  196.     }
  197.     public function addMatricula(SsoMatricula $matricula): self
  198.     {
  199.         if (!$this->matriculas->contains($matricula)) {
  200.             $this->matriculas[] = $matricula;
  201.             $matricula->setPersona($this);
  202.         }
  203.         return $this;
  204.     }
  205.     public function removeMatricula(SsoMatricula $matricula): self
  206.     {
  207.         if ($this->matriculas->removeElement($matricula)) {
  208.             // set the owning side to null (unless already changed)
  209.             if ($matricula->getPersona() === $this) {
  210.                 $matricula->setPersona(null);
  211.             }
  212.         }
  213.         return $this;
  214.     }
  215.     public function getUrlDni(): ?string
  216.     {
  217.         return $this->urlDni;
  218.     }
  219.     public function setUrlDni(?string $urlDni): self
  220.     {
  221.         $this->urlDni $urlDni;
  222.         return $this;
  223.     }
  224.     /**
  225.      * @return Collection|SsoFirmaPersona[]
  226.      */
  227.     public function getFirmasPersona(): Collection
  228.     {
  229.         return $this->firmasPersona;
  230.     }
  231.     public function addFirmasPersona(SsoFirmaPersona $firmasPersona): self
  232.     {
  233.         if (!$this->firmasPersona->contains($firmasPersona)) {
  234.             $this->firmasPersona[] = $firmasPersona;
  235.             $firmasPersona->setPersona($this);
  236.         }
  237.         return $this;
  238.     }
  239.     public function removeFirmasPersona(SsoFirmaPersona $firmasPersona): self
  240.     {
  241.         if ($this->firmasPersona->removeElement($firmasPersona)) {
  242.             // set the owning side to null (unless already changed)
  243.             if ($firmasPersona->getPersona() === $this) {
  244.                 $firmasPersona->setPersona(null);
  245.             }
  246.         }
  247.         return $this;
  248.     }
  249. }