<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use App\Entity\Prestataire;
use App\Misc\StringUtils;
/**
* Departement
*
* @ORM\Table(name="Departement")
* @ORM\Entity(repositoryClass="App\Entity\DepartementRepository")
*/
class Departement
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="code", type="string", length=10)
*/
private $code;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=60)
*/
private $nom;
/**
* @var string
*
* @ORM\Column(name="slug", type="string", length=255)
*/
private $slug;
/**
* @var Region
*
* @ORM\ManyToOne(targetEntity="Region")
* @ORM\JoinColumn(name="region_id", referencedColumnName="id", nullable=true)
*/
private $region;
/**
* @var ArrayCollection
*
* @ORM\ManyToMany(targetEntity="Prestataire", mappedBy="departements")
*/
private $prestataires;
public function __construct()
{
$this->prestataires = new ArrayCollection();
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set code
*
* @param string $code
*
* @return Departement
*/
public function setCode($code)
{
$this->code = $code;
return $this;
}
/**
* Get code
*
* @return string
*/
public function getCode()
{
return $this->code;
}
/**
* @param string $nom
*
* @return Departement
*/
public function setNom($nom)
{
$this->nom = $nom;
return $this;
}
/**
* @return string
*/
public function getNom()
{
return $this->nom;
}
/**
* @param string $slug
*
* @return Departement
*/
public function setSlug($slug): self
{
$this->slug = StringUtils::sanitizeString($slug);
return $this;
}
/**
* @return string
*/
public function getSlug()
{
return StringUtils::sanitizeString($this->slug);
}
/**
* @return Region
*/
public function getRegion()
{
return $this->region;
}
/**
* @param Region $region
*/
public function setRegion($region)
{
$this->region = $region;
}
/**
* Add prestataires
*
* @param Prestataire $prestataire
*
* @return Departement
*/
public function addPrestataire(Prestataire $prestataire)
{
$this->prestataires[] = $prestataire;
return $this;
}
/**
* Remove prestataires
*
* @param Prestataire $prestataire
*/
public function removePrestataire(Prestataire $prestataire)
{
$this->prestataires->removeElement($prestataire);
}
/**
* Get prestataires
*
* @return Collection
*/
public function getPrestataires()
{
return $this->prestataires;
}
public function __toString()
{
return $this->code .' – '. $this->getNom();
}
}