<?php
namespace App\Entity;
use App\Repository\DelegationRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: DelegationRepository::class)]
class Delegation
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'string', length: 255)]
private $libelle;
#[ORM\OneToMany(mappedBy: 'delegation', targetEntity: Adresse::class)]
private $adresses;
#[ORM\ManyToOne(inversedBy: 'delegations')]
private ?Gouvernorat $gouvernorat = null;
public function __construct()
{
$this->adresses = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getLibelle(): ?string
{
return $this->libelle;
}
public function setLibelle(string $libelle): self
{
$this->libelle = $libelle;
return $this;
}
public function __toString()
{
return (string)$this->getLibelle();
}
/**
* @return Collection<int, Adresse>
*/
public function getAdresses(): Collection
{
return $this->adresses;
}
public function addAdress(Adresse $adress): self
{
if (!$this->adresses->contains($adress)) {
$this->adresses->add($adress);
$adress->setDelegation($this);
}
return $this;
}
public function removeAdress(Adresse $adress): self
{
if ($this->adresses->removeElement($adress)) {
// set the owning side to null (unless already changed)
if ($adress->getDelegation() === $this) {
$adress->setDelegation(null);
}
}
return $this;
}
public function getGouvernorat(): ?Gouvernorat
{
return $this->gouvernorat;
}
public function setGouvernorat(?Gouvernorat $gouvernorat): self
{
$this->gouvernorat = $gouvernorat;
return $this;
}
}