src/Entity/Sector.php line 11

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\SectorRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassSectorRepository::class)]
  8. class Sector
  9. {
  10.     #[ORM\Id]
  11.     #[ORM\GeneratedValue]
  12.     #[ORM\Column]
  13.     private ?int $id null;
  14.     #[ORM\Column(length100uniquetrue)]
  15.     private ?string $name null;
  16.     #[ORM\Column(length100uniquetrue)]
  17.     private ?string $slug null;
  18.     #[ORM\OneToMany(mappedBy'secteur'targetEntityEmplacement::class, fetch'EAGER')]
  19.     private Collection $emplacements;
  20.     public function __construct()
  21.     {
  22.         $this->emplacements = new ArrayCollection();
  23.     }
  24.     public function __toString(): string
  25.     {
  26.         return $this->getName();
  27.     }
  28.     public function getId(): ?int
  29.     {
  30.         return $this->id;
  31.     }
  32.     public function getName(): ?string
  33.     {
  34.         return $this->name;
  35.     }
  36.     public function setName(string $name): self
  37.     {
  38.         $this->name $name;
  39.         return $this;
  40.     }
  41.     public function getSlug(): ?string
  42.     {
  43.         return $this->slug;
  44.     }
  45.     public function setSlug(string $slug): self
  46.     {
  47.         $this->slug $slug;
  48.         return $this;
  49.     }
  50.     /**
  51.      * @return Collection<int, Emplacement>
  52.      */
  53.     public function getEmplacements(): Collection
  54.     {
  55.         return $this->emplacements;
  56.     }
  57.     public function addEmplacement(Emplacement $emplacement): self
  58.     {
  59.         if (!$this->emplacements->contains($emplacement)) {
  60.             $this->emplacements->add($emplacement);
  61.             $emplacement->setSecteur($this);
  62.         }
  63.         return $this;
  64.     }
  65.     public function removeEmplacement(Emplacement $emplacement): self
  66.     {
  67.         if ($this->emplacements->removeElement($emplacement)) {
  68.             // set the owning side to null (unless already changed)
  69.             if ($emplacement->getSecteur() === $this) {
  70.                 $emplacement->setSecteur(null);
  71.             }
  72.         }
  73.         return $this;
  74.     }
  75. }