src/Entity/ParNivelCargo.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ParNivelCargoRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassParNivelCargoRepository::class)]
  8. class ParNivelCargo
  9. {
  10.     #[ORM\Id]
  11.     #[ORM\GeneratedValue]
  12.     #[ORM\Column]
  13.     private ?int $id null;
  14.     #[ORM\Column(length100)]
  15.     private ?string $nombre null;
  16.     #[ORM\ManyToMany(targetEntityTerPersona::class, mappedBy'nivelCargo')]
  17.     private Collection $persona;
  18.     public function __construct()
  19.     {
  20.         $this->persona = new ArrayCollection();
  21.     }
  22.     
  23.     public function __toString() {
  24.         return $this->getNombre();
  25.     }
  26.     public function getId(): ?int
  27.     {
  28.         return $this->id;
  29.     }
  30.     public function getNombre(): ?string
  31.     {
  32.         return $this->nombre;
  33.     }
  34.     public function setNombre(string $nombre): static
  35.     {
  36.         $this->nombre $nombre;
  37.         return $this;
  38.     }
  39.     /**
  40.      * @return Collection<int, TerPersona>
  41.      */
  42.     public function getPersona(): Collection
  43.     {
  44.         return $this->persona;
  45.     }
  46.     public function addPersona(TerPersona $persona): static
  47.     {
  48.         if (!$this->persona->contains($persona)) {
  49.             $this->persona->add($persona);
  50.             $persona->addNivelCargo($this);
  51.         }
  52.         return $this;
  53.     }
  54.     public function removePersona(TerPersona $persona): static
  55.     {
  56.         if ($this->persona->removeElement($persona)) {
  57.             $persona->removeNivelCargo($this);
  58.         }
  59.         return $this;
  60.     }
  61. }