<?php
namespace App\Entity;
use App\Repository\EmpresaFormacionRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Entity(repositoryClass: EmpresaFormacionRepository::class)]
class EmpresaFormacion
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[Assert\NotBlank]
#[ORM\Column(type: 'string', length: 255)]
private ?string $nombre = null;
#[ORM\Column(type: 'boolean')]
private bool $visible = true;
#[ORM\Column(type: 'boolean')]
private bool $borrado = false;
#[ORM\OneToMany(targetEntity: Curso::class, mappedBy: 'empresaFormacion')]
private Collection $cursos;
#[ORM\Column(length: 9)]
#[Assert\NotBlank]
#[Assert\Regex(pattern: '#(^[ABCDEFGHJKLMNPQRSUVWabcdefghjklmnpqrsuvw]\d{7}[0-9A-J])$|(^\d{8}[TRWAGMYFPDXBNJZSQVHLCKEtrwagmyfpdxbnjzsqvhlcke]$)#')]
private ?string $cif = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $email = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $personaContacto = null;
#[ORM\Column(length: 9, nullable: true)]
#[Assert\Regex(pattern: '/^\d{9}$/i')]
private ?string $telefonoPersonaContacto = null;
#[ORM\OneToMany(mappedBy: 'empresaFormacion', targetEntity: Usuario::class)]
private Collection $usuarios;
public function __construct()
{
$this->cursos = new ArrayCollection();
$this->usuarios = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getNombre(): ?string
{
return $this->nombre;
}
public function setNombre(string $nombre): self
{
$this->nombre = $nombre;
return $this;
}
public function isVisible(): ?bool
{
return $this->visible;
}
public function setVisible(bool $visible): self
{
$this->visible = $visible;
return $this;
}
public function isBorrado(): ?bool
{
return $this->borrado;
}
public function setBorrado(bool $borrado): self
{
$this->borrado = $borrado;
return $this;
}
/**
* @return Collection<int, Curso>
*/
public function getCursos(): Collection
{
return $this->cursos;
}
public function addCurso(Curso $curso): self
{
if (!$this->cursos->contains($curso)) {
$this->cursos[] = $curso;
$curso->setEmpresaFormacion($this);
}
return $this;
}
public function removeCurso(Curso $curso): self
{
// set the owning side to null (unless already changed)
if ($this->cursos->removeElement($curso) && $curso->getEmpresaFormacion() === $this) {
$curso->setEmpresaFormacion(null);
}
return $this;
}
public function getCif(): ?string
{
return $this->cif;
}
public function setCif(string $cif): static
{
$this->cif = mb_strtoupper($cif);
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(?string $email): static
{
$this->email = $email;
return $this;
}
public function getPersonaContacto(): ?string
{
return $this->personaContacto;
}
public function setPersonaContacto(?string $personaContacto): static
{
$this->personaContacto = $personaContacto;
return $this;
}
public function getTelefonoPersonaContacto(): ?string
{
return $this->telefonoPersonaContacto;
}
public function setTelefonoPersonaContacto(string $telefonoPersonaContacto): static
{
$this->telefonoPersonaContacto = $telefonoPersonaContacto;
return $this;
}
/**
* @return Collection<int, Usuario>
*/
public function getUsuarios(): Collection
{
return $this->usuarios;
}
public function addUsuario(Usuario $usuario): static
{
if (!$this->usuarios->contains($usuario)) {
$this->usuarios->add($usuario);
$usuario->setEmpresaFormacion($this);
}
return $this;
}
public function removeUsuario(Usuario $usuario): static
{
if ($this->usuarios->removeElement($usuario)) {
// set the owning side to null (unless already changed)
if ($usuario->getEmpresaFormacion() === $this) {
$usuario->setEmpresaFormacion(null);
}
}
return $this;
}
}