<?php
namespace App\Entity;
use App\Repository\ProvinceRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=ProvinceRepository::class)
*/
class Province
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=75, nullable=true)
*/
private $nom;
/**
* @ORM\OneToMany(targetEntity=Federation::class, mappedBy="province")
*/
private $federations;
/**
* @ORM\Column(type="string", length=155, nullable=true)
*/
private $president;
/**
* @ORM\OneToOne(targetEntity=User::class, cascade={"persist", "remove"})
*/
private $user;
/**
* @ORM\OneToMany(targetEntity=Commune::class, mappedBy="province", orphanRemoval=true)
*/
private $communes;
/**
* @ORM\OneToMany(targetEntity=District::class, mappedBy="province")
*/
private $districts;
public function __construct()
{
$this->federations = new ArrayCollection();
$this->communes = new ArrayCollection();
$this->districts = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getNom(): ?string
{
return $this->nom;
}
public function setNom(?string $nom): self
{
$this->nom = $nom;
return $this;
}
/**
* @return Collection<int, Federation>
*/
public function getFederations(): Collection
{
return $this->federations;
}
public function addFederation(Federation $federation): self
{
if (!$this->federations->contains($federation)) {
$this->federations[] = $federation;
$federation->setProvince($this);
}
return $this;
}
public function removeFederation(Federation $federation): self
{
if ($this->federations->removeElement($federation)) {
// set the owning side to null (unless already changed)
if ($federation->getProvince() === $this) {
$federation->setProvince(null);
}
}
return $this;
}
public function getPresident(): ?string
{
return $this->president;
}
public function setPresident(?string $president): self
{
$this->president = $president;
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
/**
* @return Collection<int, Commune>
*/
public function getCommunes(): Collection
{
return $this->communes;
}
public function addCommune(Commune $commune): self
{
if (!$this->communes->contains($commune)) {
$this->communes[] = $commune;
$commune->setProvince($this);
}
return $this;
}
public function removeCommune(Commune $commune): self
{
if ($this->communes->removeElement($commune)) {
// set the owning side to null (unless already changed)
if ($commune->getProvince() === $this) {
$commune->setProvince(null);
}
}
return $this;
}
/**
* @return Collection<int, District>
*/
public function getDistricts(): Collection
{
return $this->districts;
}
public function addDistrict(District $district): self
{
if (!$this->districts->contains($district)) {
$this->districts[] = $district;
$district->setProvince($this);
}
return $this;
}
public function removeDistrict(District $district): self
{
if ($this->districts->removeElement($district)) {
// set the owning side to null (unless already changed)
if ($district->getProvince() === $this) {
$district->setProvince(null);
}
}
return $this;
}
}