<?php
namespace App\Entity;
use App\Repository\InscripcionUsuarioJornadaCursoRepository;
use DateTime;
use DateTimeInterface;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use App\Validator as CustomAssert;
use Symfony\Component\Validator\Constraints as Assert;
#[UniqueEntity(
fields: ['email', 'jornadaCurso'],
message: 'Ya hay un registro con ese email en esta jornada.',
)]
#[UniqueEntity(
fields: ['dniNie', 'jornadaCurso'],
message: 'Ya hay un registro con ese DNI/NIE en esta jornada.',
)]
#[ORM\Entity(repositoryClass: InscripcionUsuarioJornadaCursoRepository::class)]
class InscripcionUsuarioJornadaCurso
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\ManyToOne(inversedBy: 'inscripcionesUsuariosJornadasCursos')]
#[ORM\JoinColumn(nullable: false)]
private ?JornadaCurso $jornadaCurso = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE)]
private ?DateTimeInterface $fechaHora;
#[Assert\NotBlank]
#[Assert\Email]
#[Assert\Length(max: 190)]
#[ORM\Column(type: 'string', length: 255)]
private ?string $email = null;
#[Assert\NotBlank]
#[Assert\Length(max: 255)]
#[ORM\Column(type: 'string', length: 255)]
private ?string $nombre = null;
#[Assert\NotBlank]
#[Assert\Length(max: 255)]
#[ORM\Column(type: 'string', length: 255)]
private ?string $apellidos = null;
#[Assert\NotBlank]
#[CustomAssert\IsDniNie]
#[ORM\Column(type: 'string', length: 9)]
private ?string $dniNie = null;
#[Assert\NotBlank]
#[ORM\Column(type: 'date', nullable: true)]
private ?DateTimeInterface $fechaNacimiento = null;
#[Assert\NotBlank]
#[ORM\ManyToOne(targetEntity: SexoUsuario::class, inversedBy: 'usuarios')]
private ?SexoUsuario $sexo = null;
#[Assert\NotBlank]
#[ORM\ManyToOne(targetEntity: Localidad::class, inversedBy: 'usuarios')]
private ?Localidad $localidad = null;
#[Assert\NotBlank]
#[ORM\Column(type: 'string', length: 255)]
private ?string $direccion = null;
#[Assert\NotBlank]
#[Assert\Regex(pattern: '/^\d{5}$/')]
#[ORM\Column(type: 'string', length: 5)]
private ?string $codigoPostal = null;
#[Assert\NotBlank]
#[Assert\Regex(pattern: '/^\d{9}$/')]
#[ORM\Column(type: 'string', length: 9)]
private ?string $telefono1 = null;
#[Assert\Regex(pattern: '/^\d{9}$/')]
#[ORM\Column(type: 'string', length: 9, nullable: true)]
private ?string $telefono2 = null;
#[ORM\Column]
private ?bool $aceptaCondicionesPrivacidad = false;
#[ORM\ManyToOne(inversedBy: 'inscripcionesJornadasCursos')]
#[ORM\JoinColumn(nullable: false)]
private ?Usuario $usuario = null;
public function __construct()
{
$this->fechaHora = new DateTime();
}
public function getId(): ?int
{
return $this->id;
}
public function getJornadaCurso(): ?JornadaCurso
{
return $this->jornadaCurso;
}
public function setJornadaCurso(?JornadaCurso $jornadaCurso): static
{
$this->jornadaCurso = $jornadaCurso;
return $this;
}
public function getFechaHora(): ?DateTimeInterface
{
return $this->fechaHora;
}
public function setFechaHora(DateTimeInterface $fechaHora): static
{
$this->fechaHora = $fechaHora;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(?string $email): self
{
$this->email = $email;
return $this;
}
public function getNombre(): ?string
{
return $this->nombre;
}
public function setNombre(?string $nombre): self
{
$this->nombre = $nombre;
return $this;
}
public function getApellidos(): ?string
{
return $this->apellidos;
}
public function setApellidos(?string $apellidos): self
{
$this->apellidos = $apellidos;
return $this;
}
public function getDniNie(): ?string
{
return $this->dniNie;
}
public function setDniNie(?string $dniNie): self
{
$this->dniNie = $dniNie;
return $this;
}
public function getFechaNacimiento(): ?DateTimeInterface
{
return $this->fechaNacimiento;
}
public function setFechaNacimiento(?DateTimeInterface $fechaNacimiento): self
{
$this->fechaNacimiento = $fechaNacimiento;
return $this;
}
public function getSexo(): ?SexoUsuario
{
return $this->sexo;
}
public function setSexo(?SexoUsuario $sexo): self
{
$this->sexo = $sexo;
return $this;
}
public function getLocalidad(): ?Localidad
{
return $this->localidad;
}
public function setLocalidad(?Localidad $localidad): self
{
$this->localidad = $localidad;
return $this;
}
public function getDireccion(): ?string
{
return $this->direccion;
}
public function setDireccion(?string $direccion): self
{
$this->direccion = $direccion;
return $this;
}
public function getCodigoPostal(): ?string
{
return $this->codigoPostal;
}
public function setCodigoPostal(?string $codigoPostal): self
{
$this->codigoPostal = $codigoPostal;
return $this;
}
public function getTelefono1(): ?string
{
return $this->telefono1;
}
public function setTelefono1(?string $telefono1): self
{
$this->telefono1 = $telefono1;
return $this;
}
public function getTelefono2(): ?string
{
return $this->telefono2;
}
public function setTelefono2(?string $telefono2): self
{
$this->telefono2 = $telefono2;
return $this;
}
public function isAceptaCondicionesPrivacidad(): ?bool
{
return $this->aceptaCondicionesPrivacidad;
}
public function setAceptaCondicionesPrivacidad(bool $aceptaCondicionesPrivacidad): static
{
$this->aceptaCondicionesPrivacidad = $aceptaCondicionesPrivacidad;
return $this;
}
public function getUsuario(): ?Usuario
{
return $this->usuario;
}
public function setUsuario(?Usuario $usuario): static
{
$this->usuario = $usuario;
return $this;
}
}