src\Entity\Empresa.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\EmpresaRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassEmpresaRepository::class)]
  8. #[ORM\HasLifecycleCallbacks]
  9. class Empresa
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column]
  14.     private ?int $id null;
  15.     #[ORM\Column(length255)]
  16.     private ?string $nome null;
  17.     #[ORM\OneToMany(mappedBy'empresa'targetEntitySolicitacao::class)]
  18.     private Collection $solicitacoes;
  19.     #[ORM\ManyToMany(targetEntityUser::class, inversedBy'empresas')]
  20.     private Collection $users;
  21.     #[ORM\Column(length255)]
  22.     private ?string $slug null;
  23.     #[ORM\Column(length255nullabletrue)]
  24.     private ?string $path null;
  25.     #[ORM\Column]
  26.     private ?\DateTimeImmutable $createdAt null;
  27.     #[ORM\Column(nullabletrue)]
  28.     private ?\DateTimeImmutable $updatedAt null;
  29.     #[ORM\Column(nullabletrue)]
  30.     private ?\DateTimeImmutable $deletedAt null;
  31.     #[ORM\OneToMany(mappedBy'empresa'targetEntitySubEmpresa::class, fetch'EAGER')]
  32.     private Collection $subEmpresas;
  33.     public function __construct()
  34.     {
  35.         $this->users = new ArrayCollection();
  36.         $this->solicitacoes = new ArrayCollection();
  37.         $this->createdAt = new \DateTimeImmutable();
  38.         $this->subEmpresas = new ArrayCollection();
  39.     }
  40.     #[ORM\PreUpdate]
  41.     public function setUpdatedAtValue(): void
  42.     {
  43.         $this->updatedAt = new \DateTimeImmutable();
  44.     }
  45.     public function getId(): ?int
  46.     {
  47.         return $this->id;
  48.     }
  49.     public function getNome(): ?string
  50.     {
  51.         return $this->nome;
  52.     }
  53.     public function setNome(string $nome): self
  54.     {
  55.         $this->nome $nome;
  56.         return $this;
  57.     }
  58.     public function getUsers(): Collection
  59.     {
  60.         return $this->users;
  61.     }
  62.     public function addUser(User $user): self
  63.     {
  64.         if (!$this->users->contains($user)) {
  65.             $this->users->add($user);
  66.         }
  67.         return $this;
  68.     }
  69.     public function removeUser(User $user): self
  70.     {
  71.         $this->users->removeElement($user);
  72.         return $this;
  73.     }
  74.     public function getSlug(): ?string
  75.     {
  76.         return $this->slug;
  77.     }
  78.     public function setSlug(string $slug): self
  79.     {
  80.         $this->slug $slug;
  81.         return $this;
  82.     }
  83.     public function getPath(): ?string
  84.     {
  85.         return $this->path;
  86.     }
  87.     public function setPath(?string $path): self
  88.     {
  89.         $this->path $path;
  90.         return $this;
  91.     }
  92.     public function getCreatedAt(): ?\DateTimeImmutable
  93.     {
  94.         return $this->createdAt;
  95.     }
  96.     public function getUpdatedAt(): ?\DateTimeImmutable
  97.     {
  98.         return $this->updatedAt;
  99.     }
  100.     public function setUpdatedAt(?\DateTimeImmutable $updatedAt): self
  101.     {
  102.         $this->updatedAt $updatedAt;
  103.         return $this;
  104.     }
  105.     public function getDeletedAt(): ?\DateTimeImmutable
  106.     {
  107.         return $this->deletedAt;
  108.     }
  109.     public function setDeletedAt(?\DateTimeImmutable $deletedAt): self
  110.     {
  111.         $this->deletedAt $deletedAt;
  112.         return $this;
  113.     }
  114.     public function getSolicitacoes(): Collection
  115.     {
  116.         return $this->solicitacoes;
  117.     }
  118.     public function addSolicitacao(Solicitacao $solicitacao): self
  119.     {
  120.         if (!$this->solicitacoes->contains($solicitacao)) {
  121.             $this->solicitacoes[] = $solicitacao;
  122.             $solicitacao->setEmpresa($this);
  123.         }
  124.         return $this;
  125.     }
  126.     public function removeSolicitacao(Solicitacao $solicitacao): self
  127.     {
  128.         if ($this->solicitacoes->removeElement($solicitacao)) {
  129.             if ($solicitacao->getEmpresa() === $this) {
  130.                 $solicitacao->setEmpresa(null);
  131.             }
  132.         }
  133.         return $this;
  134.     }
  135.     public function getSubEmpresas(): Collection
  136.     {
  137.         return $this->subEmpresas;
  138.     }
  139.     public function addSubEmpresa(SubEmpresa $subEmpresa): self
  140.     {
  141.         if (!$this->subEmpresas->contains($subEmpresa)) {
  142.             $this->subEmpresas->add($subEmpresa);
  143.             $subEmpresa->setEmpresa($this);
  144.         }
  145.         return $this;
  146.     }
  147.     public function removeSubEmpresa(SubEmpresa $subEmpresa): self
  148.     {
  149.         if ($this->subEmpresas->removeElement($subEmpresa)) {
  150.             $subEmpresa->setEmpresa(null);
  151.         }
  152.         return $this;
  153.     }
  154. }