<?php
namespace App\Entity;
use App\Repository\EmpresaRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: EmpresaRepository::class)]
#[ORM\HasLifecycleCallbacks]
class Empresa
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $nome = null;
#[ORM\OneToMany(mappedBy: 'empresa', targetEntity: Solicitacao::class)]
private Collection $solicitacoes;
#[ORM\ManyToMany(targetEntity: User::class, inversedBy: 'empresas')]
private Collection $users;
#[ORM\Column(length: 255)]
private ?string $slug = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $path = null;
#[ORM\Column]
private ?\DateTimeImmutable $createdAt = null;
#[ORM\Column(nullable: true)]
private ?\DateTimeImmutable $updatedAt = null;
#[ORM\Column(nullable: true)]
private ?\DateTimeImmutable $deletedAt = null;
#[ORM\OneToMany(mappedBy: 'empresa', targetEntity: SubEmpresa::class, fetch: 'EAGER')]
private Collection $subEmpresas;
public function __construct()
{
$this->users = new ArrayCollection();
$this->solicitacoes = new ArrayCollection();
$this->createdAt = new \DateTimeImmutable();
$this->subEmpresas = new ArrayCollection();
}
#[ORM\PreUpdate]
public function setUpdatedAtValue(): void
{
$this->updatedAt = new \DateTimeImmutable();
}
public function getId(): ?int
{
return $this->id;
}
public function getNome(): ?string
{
return $this->nome;
}
public function setNome(string $nome): self
{
$this->nome = $nome;
return $this;
}
public function getUsers(): Collection
{
return $this->users;
}
public function addUser(User $user): self
{
if (!$this->users->contains($user)) {
$this->users->add($user);
}
return $this;
}
public function removeUser(User $user): self
{
$this->users->removeElement($user);
return $this;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(string $slug): self
{
$this->slug = $slug;
return $this;
}
public function getPath(): ?string
{
return $this->path;
}
public function setPath(?string $path): self
{
$this->path = $path;
return $this;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
public function getUpdatedAt(): ?\DateTimeImmutable
{
return $this->updatedAt;
}
public function setUpdatedAt(?\DateTimeImmutable $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
public function getDeletedAt(): ?\DateTimeImmutable
{
return $this->deletedAt;
}
public function setDeletedAt(?\DateTimeImmutable $deletedAt): self
{
$this->deletedAt = $deletedAt;
return $this;
}
public function getSolicitacoes(): Collection
{
return $this->solicitacoes;
}
public function addSolicitacao(Solicitacao $solicitacao): self
{
if (!$this->solicitacoes->contains($solicitacao)) {
$this->solicitacoes[] = $solicitacao;
$solicitacao->setEmpresa($this);
}
return $this;
}
public function removeSolicitacao(Solicitacao $solicitacao): self
{
if ($this->solicitacoes->removeElement($solicitacao)) {
if ($solicitacao->getEmpresa() === $this) {
$solicitacao->setEmpresa(null);
}
}
return $this;
}
public function getSubEmpresas(): Collection
{
return $this->subEmpresas;
}
public function addSubEmpresa(SubEmpresa $subEmpresa): self
{
if (!$this->subEmpresas->contains($subEmpresa)) {
$this->subEmpresas->add($subEmpresa);
$subEmpresa->setEmpresa($this);
}
return $this;
}
public function removeSubEmpresa(SubEmpresa $subEmpresa): self
{
if ($this->subEmpresas->removeElement($subEmpresa)) {
$subEmpresa->setEmpresa(null);
}
return $this;
}
}