src/Entity/UserProfile.php line 10

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\UserProfileRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Component\Validator\Constraints as Assert;
  6. #[ORM\Entity(repositoryClassUserProfileRepository::class)]
  7. class UserProfile
  8. {
  9.     public const TIPO_FORMADOR_INTERNO 'interno';
  10.     public const TIPO_FORMADOR_EMPRESA_EXTERNA 'empresa_externa';
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column]
  14.     private ?int $id null;
  15.     #[ORM\OneToOne(inversedBy'profile')]
  16.     #[ORM\JoinColumn(nullablefalseonDelete'CASCADE')]
  17.     private ?User $user null;
  18.     // ===== DATOS PERSONALES =====
  19.     #[ORM\Column(length100)]
  20.     private string $nombre;
  21.     #[ORM\Column(length100)]
  22.     private string $apellido1;
  23.     #[ORM\Column(length100)]
  24.     private string $apellido2;
  25.     #[ORM\Column(type'date')]
  26.     private ?\DateTimeInterface $fechaNacimiento null;
  27.     #[Assert\NotBlank(message'El genero es obligatorio')]
  28.     #[ORM\Column(length10)]
  29.     private string $sexo;
  30.     // ===== DIRECCIÓN (OPCIONAL) =====
  31.     #[ORM\Column(length50nullabletrue)]
  32.     private ?string $tipoVia null;
  33.     #[ORM\Column(length150nullabletrue)]
  34.     private ?string $nombreVia null;
  35.     #[ORM\Column(length10nullabletrue)]
  36.     private ?string $numeroVia null;
  37.     #[ORM\Column(length10nullabletrue)]
  38.     private ?string $codigoPostal null;
  39.     #[ORM\Column(length100nullabletrue)]
  40.     private ?string $provincia null;
  41.     #[ORM\Column(length100nullabletrue)]
  42.     private ?string $municipio null;
  43.     #[ORM\Column(length10nullabletrue)]
  44.     private ?string $portal null;
  45.     #[ORM\Column(length10nullabletrue)]
  46.     private ?string $bloque null;
  47.     #[ORM\Column(length10nullabletrue)]
  48.     private ?string $escalera null;
  49.     #[ORM\Column(length10nullabletrue)]
  50.     private ?string $planta null;
  51.     #[ORM\Column(length10nullabletrue)]
  52.     private ?string $puerta null;
  53.     #[Assert\Regex(
  54.         pattern'/^(?:\+34|0034)?[6-7]\d{8}$/',
  55.         message'Introduzca un número de móvil válido'
  56.     )]
  57.     #[ORM\Column(length20nullabletrue)]
  58.     private ?string $telefono null;
  59.     // ===== VINCULACIÓN PROFESIONAL =====
  60.     #[ORM\Column(length30nullabletrue)]
  61.     private ?string $tipoFormador null;
  62.     // ===== DATOS LABORALES =====
  63.     #[ORM\ManyToOne]
  64.     #[ORM\JoinColumn(nullabletrue)]
  65.     private ?TaxonomyValue $centroTrabajo null;
  66.     #[ORM\ManyToOne]
  67.     #[ORM\JoinColumn(nullabletrue)]
  68.     private ?TaxonomyValue $puestoTrabajo null;
  69.     #[ORM\ManyToOne]
  70.     #[ORM\JoinColumn(nullabletrue)]
  71.     private ?TaxonomyValue $especialidad null;
  72.     #[ORM\ManyToOne]
  73.     #[ORM\JoinColumn(nullabletrue)]
  74.     private ?TaxonomyValue $grupo null;
  75.     #[ORM\ManyToOne]
  76.     #[ORM\JoinColumn(nullabletrue)]
  77.     private ?TaxonomyValue $situacionLaboral null;
  78.     // ===== EMPRESA EXTERNA =====
  79.     #[ORM\Column(length255nullabletrue)]
  80.     private ?string $entidadExterna null;
  81.     #[ORM\Column(length20nullabletrue)]
  82.     private ?string $cifEntidadExterna null;
  83.     #[ORM\Column(length255nullabletrue)]
  84.     private ?string $direccionEntidadExterna null;
  85.     #[ORM\Column(length255nullabletrue)]
  86.     private ?string $contactoEntidadExterna null;
  87.     // ================== GETTERS & SETTERS ==================
  88.     public function getId(): ?int
  89.     {
  90.         return $this->id;
  91.     }
  92.     public function getUser(): ?User
  93.     {
  94.         return $this->user;
  95.     }
  96.     public function setUser(User $user): self
  97.     {
  98.         $this->user $user;
  99.         return $this;
  100.     }
  101.     public function getNombre(): string
  102.     {
  103.         return $this->nombre;
  104.     }
  105.     public function setNombre(string $nombre): self
  106.     {
  107.         $this->nombre $nombre;
  108.         return $this;
  109.     }
  110.     public function getApellido1(): string
  111.     {
  112.         return $this->apellido1;
  113.     }
  114.     public function setApellido1(string $apellido1): self
  115.     {
  116.         $this->apellido1 $apellido1;
  117.         return $this;
  118.     }
  119.     public function getApellido2(): string
  120.     {
  121.         return $this->apellido2;
  122.     }
  123.     public function setApellido2(string $apellido2): self
  124.     {
  125.         $this->apellido2 $apellido2;
  126.         return $this;
  127.     }
  128.     public function getFechaNacimiento(): ?\DateTimeInterface
  129.     {
  130.         return $this->fechaNacimiento;
  131.     }
  132.     public function setFechaNacimiento(?\DateTimeInterface $fechaNacimiento): self
  133.     {
  134.         $this->fechaNacimiento $fechaNacimiento;
  135.         return $this;
  136.     }
  137.     public function getSexo(): string
  138.     {
  139.         return $this->sexo;
  140.     }
  141.     public function setSexo(string $sexo): self
  142.     {
  143.         $this->sexo $sexo;
  144.         return $this;
  145.     }
  146.     public function getTipoVia(): ?string
  147.     {
  148.         return $this->tipoVia;
  149.     }
  150.     public function setTipoVia(?string $tipoVia): self
  151.     {
  152.         $this->tipoVia $tipoVia;
  153.         return $this;
  154.     }
  155.     public function getNombreVia(): ?string
  156.     {
  157.         return $this->nombreVia;
  158.     }
  159.     public function setNombreVia(?string $nombreVia): self
  160.     {
  161.         $this->nombreVia $nombreVia;
  162.         return $this;
  163.     }
  164.     public function getNumeroVia(): ?string
  165.     {
  166.         return $this->numeroVia;
  167.     }
  168.     public function setNumeroVia(?string $numeroVia): self
  169.     {
  170.         $this->numeroVia $numeroVia;
  171.         return $this;
  172.     }
  173.     public function getCodigoPostal(): ?string
  174.     {
  175.         return $this->codigoPostal;
  176.     }
  177.     public function setCodigoPostal(?string $codigoPostal): self
  178.     {
  179.         $this->codigoPostal $codigoPostal;
  180.         return $this;
  181.     }
  182.     public function getProvincia(): ?string
  183.     {
  184.         return $this->provincia;
  185.     }
  186.     public function setProvincia(?string $provincia): self
  187.     {
  188.         $this->provincia $provincia;
  189.         return $this;
  190.     }
  191.     public function getMunicipio(): ?string
  192.     {
  193.         return $this->municipio;
  194.     }
  195.     public function setMunicipio(?string $municipio): self
  196.     {
  197.         $this->municipio $municipio;
  198.         return $this;
  199.     }
  200.     public function getPortal(): ?string
  201.     {
  202.         return $this->portal;
  203.     }
  204.     public function setPortal(?string $portal): self
  205.     {
  206.         $this->portal $portal;
  207.         return $this;
  208.     }
  209.     public function getBloque(): ?string
  210.     {
  211.         return $this->bloque;
  212.     }
  213.     public function setBloque(?string $bloque): self
  214.     {
  215.         $this->bloque $bloque;
  216.         return $this;
  217.     }
  218.     public function getEscalera(): ?string
  219.     {
  220.         return $this->escalera;
  221.     }
  222.     public function setEscalera(?string $escalera): self
  223.     {
  224.         $this->escalera $escalera;
  225.         return $this;
  226.     }
  227.     public function getPlanta(): ?string
  228.     {
  229.         return $this->planta;
  230.     }
  231.     public function setPlanta(?string $planta): self
  232.     {
  233.         $this->planta $planta;
  234.         return $this;
  235.     }
  236.     public function getPuerta(): ?string
  237.     {
  238.         return $this->puerta;
  239.     }
  240.     public function setPuerta(?string $puerta): self
  241.     {
  242.         $this->puerta $puerta;
  243.         return $this;
  244.     }
  245.     public function getTelefono(): ?string
  246.     {
  247.         return $this->telefono;
  248.     }
  249.     public function setTelefono(?string $telefono): self
  250.     {
  251.         $this->telefono $telefono;
  252.         return $this;
  253.     }
  254.     public function getTipoFormador(): ?string
  255.     {
  256.         if ($this->tipoFormador !== null) {
  257.             return $this->tipoFormador;
  258.         }
  259.         if ($this->hasExternalCompanyData()) {
  260.             return self::TIPO_FORMADOR_EMPRESA_EXTERNA;
  261.         }
  262.         if ($this->hasLaborData()) {
  263.             return self::TIPO_FORMADOR_INTERNO;
  264.         }
  265.         return null;
  266.     }
  267.     public function setTipoFormador(?string $tipoFormador): self
  268.     {
  269.         $this->tipoFormador $tipoFormador;
  270.         return $this;
  271.     }
  272.     public function getCentroTrabajo(): ?TaxonomyValue
  273.     {
  274.         return $this->centroTrabajo;
  275.     }
  276.     public function setCentroTrabajo(?TaxonomyValue $centroTrabajo): self
  277.     {
  278.         $this->centroTrabajo $centroTrabajo;
  279.         return $this;
  280.     }
  281.     public function getPuestoTrabajo(): ?TaxonomyValue
  282.     {
  283.         return $this->puestoTrabajo;
  284.     }
  285.     public function setPuestoTrabajo(?TaxonomyValue $puestoTrabajo): self
  286.     {
  287.         $this->puestoTrabajo $puestoTrabajo;
  288.         return $this;
  289.     }
  290.     public function getEspecialidad(): ?TaxonomyValue
  291.     {
  292.         return $this->especialidad;
  293.     }
  294.     public function setEspecialidad(?TaxonomyValue $especialidad): self
  295.     {
  296.         $this->especialidad $especialidad;
  297.         return $this;
  298.     }
  299.     public function getGrupo(): ?TaxonomyValue
  300.     {
  301.         return $this->grupo;
  302.     }
  303.     public function setGrupo(?TaxonomyValue $grupo): self
  304.     {
  305.         $this->grupo $grupo;
  306.         return $this;
  307.     }
  308.     public function getSituacionLaboral(): ?TaxonomyValue
  309.     {
  310.         return $this->situacionLaboral;
  311.     }
  312.     public function setSituacionLaboral(?TaxonomyValue $situacionLaboral): self
  313.     {
  314.         $this->situacionLaboral $situacionLaboral;
  315.         return $this;
  316.     }
  317.     public function getEntidadExterna(): ?string
  318.     {
  319.         return $this->entidadExterna;
  320.     }
  321.     public function setEntidadExterna(?string $entidadExterna): self
  322.     {
  323.         $this->entidadExterna $entidadExterna;
  324.         return $this;
  325.     }
  326.     public function getCifEntidadExterna(): ?string
  327.     {
  328.         return $this->cifEntidadExterna;
  329.     }
  330.     public function setCifEntidadExterna(?string $cifEntidadExterna): self
  331.     {
  332.         $this->cifEntidadExterna $cifEntidadExterna;
  333.         return $this;
  334.     }
  335.     public function getDireccionEntidadExterna(): ?string
  336.     {
  337.         return $this->direccionEntidadExterna;
  338.     }
  339.     public function setDireccionEntidadExterna(?string $direccionEntidadExterna): self
  340.     {
  341.         $this->direccionEntidadExterna $direccionEntidadExterna;
  342.         return $this;
  343.     }
  344.     public function getContactoEntidadExterna(): ?string
  345.     {
  346.         return $this->contactoEntidadExterna;
  347.     }
  348.     public function setContactoEntidadExterna(?string $contactoEntidadExterna): self
  349.     {
  350.         $this->contactoEntidadExterna $contactoEntidadExterna;
  351.         return $this;
  352.     }
  353.     public function isFormadorInterno(): bool
  354.     {
  355.         return $this->getTipoFormador() === self::TIPO_FORMADOR_INTERNO;
  356.     }
  357.     public function isEmpresaExterna(): bool
  358.     {
  359.         return $this->getTipoFormador() === self::TIPO_FORMADOR_EMPRESA_EXTERNA;
  360.     }
  361.     public function hasLaborData(): bool
  362.     {
  363.         return $this->centroTrabajo !== null
  364.             || $this->puestoTrabajo !== null
  365.             || $this->especialidad !== null
  366.             || $this->grupo !== null
  367.             || $this->situacionLaboral !== null;
  368.     }
  369.     public function hasExternalCompanyData(): bool
  370.     {
  371.         return ($this->entidadExterna !== null && trim($this->entidadExterna) !== '')
  372.             || ($this->cifEntidadExterna !== null && trim($this->cifEntidadExterna) !== '')
  373.             || ($this->direccionEntidadExterna !== null && trim($this->direccionEntidadExterna) !== '')
  374.             || ($this->contactoEntidadExterna !== null && trim($this->contactoEntidadExterna) !== '');
  375.     }
  376.     public function clearLaborData(): self
  377.     {
  378.         $this->centroTrabajo null;
  379.         $this->puestoTrabajo null;
  380.         $this->especialidad null;
  381.         $this->grupo null;
  382.         $this->situacionLaboral null;
  383.         return $this;
  384.     }
  385.     public function clearExternalCompanyData(): self
  386.     {
  387.         $this->entidadExterna null;
  388.         $this->cifEntidadExterna null;
  389.         $this->direccionEntidadExterna null;
  390.         $this->contactoEntidadExterna null;
  391.         return $this;
  392.     }
  393. }