<?php
declare(strict_types=1);
namespace App\Entity;
use App\Repository\DepartementRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* Departement.
*
* @ORM\Table(name="Departement")
*
* @ORM\Entity(repositoryClass=DepartementRepository::class)
*/
class Departement
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
*
* @ORM\Id
*
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="nom", type="string", length=255)
*/
private $nom;
/**
* @var string
*
* @ORM\Column(name="num", type="string", length=255)
*/
private $num;
/**
* @ORM\OneToMany(targetEntity="Commune", mappedBy="departement")
*/
private $communes;
/**
* @ORM\ManyToOne(targetEntity="Region", inversedBy="departements")
*
* @ORM\JoinColumn(name="region_id", referencedColumnName="id")
*/
private $region;
/**
* @ORM\OneToMany(targetEntity="Structure", mappedBy="departement")
*/
private $structures;
/**
* @ORM\OneToMany(targetEntity=FiltreStructure::class, mappedBy="departement")
*/
private $filtreStructures;
/**
* Constructor.
*/
public function __construct()
{
$this->communes = new ArrayCollection();
$this->filtreStructures = new ArrayCollection();
$this->structures = new ArrayCollection();
}
/**
* Methode pour afficher le departement.
*/
#[\Override]
public function __toString(): string
{
return $this->getNom();
}
/**
* Get id.
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set nom.
*
* @param string $nom
*/
public function setNom($nom): static
{
$this->nom = $nom;
return $this;
}
/**
* Get nom.
*
* @return string
*/
public function getNom()
{
return $this->nom;
}
/**
* Add communes.
*/
public function addCommune(Commune $communes): static
{
$this->communes[] = $communes;
return $this;
}
/**
* Remove communes.
*/
public function removeCommune(Commune $communes): void
{
$this->communes->removeElement($communes);
}
/**
* Get communes.
*
* @return Collection
*/
public function getCommunes()
{
return $this->communes;
}
/**
* Set region.
*/
public function setRegion(?Region $region = null): static
{
$this->region = $region;
return $this;
}
/**
* Get region.
*
* @return Region
*/
public function getRegion()
{
return $this->region;
}
/**
* Set num.
*
* @param string $num
*/
public function setNum($num): static
{
$this->num = $num;
return $this;
}
/**
* Get num.
*
* @return string
*/
public function getNum()
{
return $this->num;
}
/**
* Add structures.
*/
public function addStructure(Structure $structures): static
{
$this->structures[] = $structures;
return $this;
}
/**
* Remove structures.
*/
public function removeStructure(Structure $structures): void
{
$this->structures->removeElement($structures);
}
/**
* Get structures.
*
* @return Collection
*/
public function getStructures()
{
return $this->structures;
}
/**
* @return Collection<int, FiltreStructure>
*/
public function getFiltreStructures(): Collection
{
return $this->filtreStructures;
}
public function addFiltreStructure(FiltreStructure $filtreStructure): self
{
if (!$this->filtreStructures->contains($filtreStructure)) {
$this->filtreStructures[] = $filtreStructure;
$filtreStructure->setDepartement($this);
}
return $this;
}
public function removeFiltreStructure(FiltreStructure $filtreStructure): self
{
// set the owning side to null (unless already changed)
if ($this->filtreStructures->removeElement($filtreStructure) && $filtreStructure->getDepartement() === $this) {
$filtreStructure->setDepartement(null);
}
return $this;
}
}