src/Entity/Province.php line 13
<?phpnamespace 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]private ?int $id = null;#[ORM\Column(length: 255)]private ?string $nom = null;#[ORM\Column(length: 255, nullable: true)]private ?string $president = null;#[ORM\OneToOne(cascade: ['persist', 'remove'])]private ?User $user = null;/*** @var Collection<int, Federation>*/#[ORM\OneToMany(targetEntity: Federation::class, mappedBy: 'province')]private Collection $federations;/*** @var Collection<int, Commune>*/#[ORM\OneToMany(targetEntity: Commune::class, mappedBy: 'province')]private Collection $communes;/*** @var Collection<int, Communique>*/#[ORM\OneToMany(targetEntity: Communique::class, mappedBy: 'province')]private Collection $communiques;public function __construct(){$this->federations = new ArrayCollection();$this->communes = new ArrayCollection();$this->communiques = new ArrayCollection();}public function getId(): ?int{return $this->id;}public function getNom(): ?string{return $this->nom;}public function setNom(string $nom): static{$this->nom = $nom;return $this;}public function getPresident(): ?string{return $this->president;}public function setPresident(?string $president): static{$this->president = $president;return $this;}public function getUser(): ?User{return $this->user;}public function setUser(?User $user): static{$this->user = $user;return $this;}/*** @return Collection<int, Federation>*/public function getFederations(): Collection{return $this->federations;}public function addFederation(Federation $federation): static{if (!$this->federations->contains($federation)) {$this->federations->add($federation);$federation->setProvince($this);}return $this;}public function removeFederation(Federation $federation): static{if ($this->federations->removeElement($federation)) {// set the owning side to null (unless already changed)if ($federation->getProvince() === $this) {$federation->setProvince(null);}}return $this;}/*** @return Collection<int, Commune>*/public function getCommunes(): Collection{return $this->communes;}public function addCommune(Commune $commune): static{if (!$this->communes->contains($commune)) {$this->communes->add($commune);$commune->setProvince($this);}return $this;}public function removeCommune(Commune $commune): static{if ($this->communes->removeElement($commune)) {// set the owning side to null (unless already changed)if ($commune->getProvince() === $this) {$commune->setProvince(null);}}return $this;}public function getNombreMembres(): int{$totalMembres = 0;foreach ($this->federations as $federation) {$totalMembres += $federation->getMembres()->count();}return $totalMembres;}/*** @return Collection<int, Communique>*/public function getCommuniques(): Collection{return $this->communiques;}public function addCommunique(Communique $communique): static{if (!$this->communiques->contains($communique)) {$this->communiques->add($communique);$communique->setProvince($this);}return $this;}public function removeCommunique(Communique $communique): static{if ($this->communiques->removeElement($communique)) {// set the owning side to null (unless already changed)if ($communique->getProvince() === $this) {$communique->setProvince(null);}}return $this;}}