<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: \App\Repository\CantonsRepository::class)]
class Cantons implements \Stringable
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private int $id;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $canton= "";
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $territoire= "";
#[ORM\Column(type: 'text', nullable: true)]
private ?string $communes= "";
#[ORM\OneToMany(targetEntity: \App\Entity\Contact::class, mappedBy: 'canton')]
private mixed $contacts;
#[ORM\Column(type: 'text', nullable: true)]
private ?string $multipoints= "";
#[ORM\ManyToOne(targetEntity: \App\Entity\Territory::class, inversedBy: 'cantons')]
private mixed $territory;
public function __construct()
{
$this->contacts = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getCanton(): ?string
{
return $this->canton;
}
public function setCanton(?string $canton): self
{
$this->canton = $canton;
return $this;
}
public function getTerritoire(): ?string
{
return $this->territoire;
}
public function setTerritoire(?string $territoire): self
{
$this->territoire = $territoire;
return $this;
}
public function getCommunes(): ?string
{
return $this->communes;
}
public function setCommunes(?string $communes): self
{
$this->communes = $communes;
return $this;
}
/**
* @return Collection|Contact[]
*/
public function getContacts(): Collection
{
return $this->contacts;
}
public function addContact(Contact $contact): self
{
if (!$this->contacts->contains($contact)) {
$this->contacts[] = $contact;
$contact->setCanton($this);
}
return $this;
}
public function removeContact(Contact $contact): self
{
if ($this->contacts->contains($contact)) {
$this->contacts->removeElement($contact);
// set the owning side to null (unless already changed)
if ($contact->getCanton() === $this) {
$contact->setCanton(null);
}
}
return $this;
}
public function __toString(): string
{
return (string) $this->canton;
}
public function getMultipoints(): ?string
{
return $this->multipoints;
}
public function setMultipoints(?string $multipoints): self
{
$this->multipoints = $multipoints;
return $this;
}
public function getTerritory(): ?Territory
{
return $this->territory;
}
public function setTerritory(?Territory $territory): self
{
$this->territory = $territory;
return $this;
}
}