src\Entity\SubEmpresa.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\SubEmpresaRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassSubEmpresaRepository::class)]
  8. class SubEmpresa
  9. {
  10.     #[ORM\Id]
  11.     #[ORM\GeneratedValue]
  12.     #[ORM\Column]
  13.     private ?int $id null;
  14.     #[ORM\ManyToOne(targetEntityEmpresa::class, inversedBy'subEmpresas')]
  15.     private ?Empresa $empresa;
  16.     #[ORM\ManyToMany(targetEntityUser::class, inversedBy'subEmpresas')]
  17.     private Collection $users;
  18.     #[ORM\Column(length255)]
  19.     private ?string $nome null;
  20.     #[ORM\Column(length255nullabletrue)]
  21.     private ?string $descricao null;
  22.     public function __construct()
  23.     {
  24.         $this->users = new ArrayCollection();
  25.     }
  26.     public function getId(): ?int
  27.     {
  28.         return $this->id;
  29.     }
  30.     public function getEmpresa(): ?Empresa
  31.     {
  32.         return $this->empresa;
  33.     }
  34.     public function addEmpresa(?Empresa $empresa): self
  35.     {
  36.         if ($this->empresa !== $empresa) {
  37.             $this->empresa $empresa;
  38.             $empresa->addSubEmpresa($this); 
  39.         }
  40.     
  41.         return $this;
  42.     }
  43.     
  44.     public function removeEmpresa(?Empresa $empresa): self
  45.     {
  46.         if ($this->empresa === $empresa) {
  47.             $this->empresa null;
  48.             $empresa->removeSubEmpresa($this); 
  49.         }
  50.     
  51.         return $this;
  52.     }
  53.     
  54.     public function getUsers(): Collection
  55.     {
  56.         return $this->users;
  57.     }
  58.     public function addUser(User $user): self
  59.     {
  60.         if (!$this->users->contains($user)) {
  61.             $this->users->add($user);
  62.         }
  63.         return $this;
  64.     }
  65.     public function removeUser(User $user): self
  66.     {
  67.         $this->users->removeElement($user);
  68.         return $this;
  69.     }
  70.     public function getNome(): ?string
  71.     {
  72.         return $this->nome;
  73.     }
  74.     public function setNome(string $nome): self
  75.     {
  76.         $this->nome $nome;
  77.         return $this;
  78.     }
  79.     public function getDescricao(): ?string
  80.     {
  81.         return $this->descricao;
  82.     }
  83.     public function setDescricao(?string $descricao): self
  84.     {
  85.         $this->descricao $descricao;
  86.         return $this;
  87.     }
  88.     public function setEmpresa(?Empresa $empresa): self
  89. {
  90.     $this->empresa $empresa;
  91.     return $this;
  92. }
  93. }