src/Entity/Sector.php line 11
<?php
namespace App\Entity;
use App\Repository\SectorRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: SectorRepository::class)]
class Sector
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 100, unique: true)]
private ?string $name = null;
#[ORM\Column(length: 100, unique: true)]
private ?string $slug = null;
#[ORM\OneToMany(mappedBy: 'secteur', targetEntity: Emplacement::class, fetch: 'EAGER')]
private Collection $emplacements;
public function __construct()
{
$this->emplacements = new ArrayCollection();
}
public function __toString(): string
{
return $this->getName();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(string $slug): self
{
$this->slug = $slug;
return $this;
}
/**
* @return Collection<int, Emplacement>
*/
public function getEmplacements(): Collection
{
return $this->emplacements;
}
public function addEmplacement(Emplacement $emplacement): self
{
if (!$this->emplacements->contains($emplacement)) {
$this->emplacements->add($emplacement);
$emplacement->setSecteur($this);
}
return $this;
}
public function removeEmplacement(Emplacement $emplacement): self
{
if ($this->emplacements->removeElement($emplacement)) {
// set the owning side to null (unless already changed)
if ($emplacement->getSecteur() === $this) {
$emplacement->setSecteur(null);
}
}
return $this;
}
}