<?phpnamespace App\Entity;use App\Repository\AddresseRepository;use App\Repository\AddressesListRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;use Doctrine\ORM\QueryBuilder;use Doctrine\ORM\Query\Parameter;use phpDocumentor\Reflection\Types\Self_;/** * @ORM\Entity(repositoryClass=AddressesListRepository::class) */class AddressesList{ const STATUT_VIDE = 0; const STATUT_NON_GEOCODED = 1; const STATUT_GEOCODED = 3; /** * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") */ private $id; /** * @ORM\Column(type="string", length=1000, nullable=true) */ private $Description; /** * @ORM\Column(type="integer") */ private $Status; /** * @ORM\Column(type="string", length=255) */ private $Title; /** * @ORM\OneToMany(targetEntity=Addresse::class, mappedBy="AddressesGroup") */ private $addresses; /** * @ORM\OneToMany(targetEntity=Computing::class, mappedBy="AddressesGroup") */ private $computing; /** * @ORM\Column(type="boolean") */ private $locked; public function __construct() { $this->addresses = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function getDescription(): ?string { return $this->Description; } public function setDescription(string $Description): self { $this->Description = $Description; return $this; } public function getStatus(): ?int { return $this->Status; } public function setStatus(int $Status): self { $this->Status = $Status; return $this; } public function getTitle(): ?string { return $this->Title; } public function setTitle(string $Title): self { $this->Title = $Title; return $this; } /** * @return Collection<int, Addresse> */ public function getAddresses(): Collection { return $this->addresses; } public function addAddress(Addresse $address): self { if (!$this->addresses->contains($address)) { $this->addresses[] = $address; $address->setAddressesGroup($this); } return $this; } public function removeAddress(Addresse $address): self { if ($this->addresses->removeElement($address)) { // set the owning side to null (unless already changed) if ($address->getAddressesGroup() === $this) { $address->setAddressesGroup(null); } } return $this; } public function __toString() { return $this->Title; } public function getStatusTextInfo(){ switch ($this->getStatus()) { case self::STATUT_VIDE: return 'Groupe vide'; case self::STATUT_GEOCODED: return 'Groupe géocodé'; case self::STATUT_NON_GEOCODED: return 'Certaines adresses doivent être géocodées'; } } public function getStatusBadgeInfo(){ switch ($this->getStatus()) { case self::STATUT_VIDE: return 'warning'; case self::STATUT_GEOCODED: return 'success'; case self::STATUT_NON_GEOCODED: return 'warning'; } } /** * @return int */ public function getNbAddresses() { return $this->getAddresses()->count(); } public function getLocked(): ?bool { return $this->locked; } public function setLocked(bool $locked): self { $this->locked = $locked; return $this; } public function isGeocoded(){ if($this->getStatus() == self::STATUT_GEOCODED){ return true; } return false; }}