src/Entity/AddressesList.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\AddresseRepository;
  4. use App\Repository\AddressesListRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Doctrine\ORM\QueryBuilder;
  9. use Doctrine\ORM\Query\Parameter;
  10. use phpDocumentor\Reflection\Types\Self_;
  11. /**
  12.  * @ORM\Entity(repositoryClass=AddressesListRepository::class)
  13.  */
  14. class AddressesList
  15. {
  16.     const  STATUT_VIDE 0;
  17.     const  STATUT_NON_GEOCODED 1;
  18.     const  STATUT_GEOCODED 3;
  19.     /**
  20.      * @ORM\Id
  21.      * @ORM\GeneratedValue
  22.      * @ORM\Column(type="integer")
  23.      */
  24.     private $id;
  25.     /**
  26.      * @ORM\Column(type="string", length=1000, nullable=true)
  27.      */
  28.     private $Description;
  29.     /**
  30.      * @ORM\Column(type="integer")
  31.      */
  32.     private $Status;
  33.     /**
  34.      * @ORM\Column(type="string", length=255)
  35.      */
  36.     private $Title;
  37.     /**
  38.      * @ORM\OneToMany(targetEntity=Addresse::class, mappedBy="AddressesGroup")
  39.      */
  40.     private $addresses;
  41.     /**
  42.      * @ORM\OneToMany(targetEntity=Computing::class, mappedBy="AddressesGroup")
  43.      */
  44.     private $computing;
  45.     /**
  46.      * @ORM\Column(type="boolean")
  47.      */
  48.     private $locked;
  49.     public function __construct()
  50.     {
  51.         $this->addresses = new ArrayCollection();
  52.     }
  53.     public function getId(): ?int
  54.     {
  55.         return $this->id;
  56.     }
  57.     public function getDescription(): ?string
  58.     {
  59.         return $this->Description;
  60.     }
  61.     public function setDescription(string $Description): self
  62.     {
  63.         $this->Description $Description;
  64.         return $this;
  65.     }
  66.     public function getStatus(): ?int
  67.     {
  68.         return $this->Status;
  69.     }
  70.     public function setStatus(int $Status): self
  71.     {
  72.         $this->Status $Status;
  73.         return $this;
  74.     }
  75.     public function getTitle(): ?string
  76.     {
  77.         return $this->Title;
  78.     }
  79.     public function setTitle(string $Title): self
  80.     {
  81.         $this->Title $Title;
  82.         return $this;
  83.     }
  84.     /**
  85.      * @return Collection<int, Addresse>
  86.      */
  87.     public function getAddresses(): Collection
  88.     {
  89.         return $this->addresses;
  90.     }
  91.     public function addAddress(Addresse $address): self
  92.     {
  93.         if (!$this->addresses->contains($address)) {
  94.             $this->addresses[] = $address;
  95.             $address->setAddressesGroup($this);
  96.         }
  97.         return $this;
  98.     }
  99.     public function removeAddress(Addresse $address): self
  100.     {
  101.         if ($this->addresses->removeElement($address)) {
  102.             // set the owning side to null (unless already changed)
  103.             if ($address->getAddressesGroup() === $this) {
  104.                 $address->setAddressesGroup(null);
  105.             }
  106.         }
  107.         return $this;
  108.     }
  109.     public function __toString()
  110.     {
  111.         return $this->Title;
  112.     }
  113.     public function getStatusTextInfo(){
  114.         switch ($this->getStatus())
  115.         {
  116.             case self::STATUT_VIDE: return 'Groupe vide';
  117.             case self::STATUT_GEOCODED: return 'Groupe géocodé';
  118.             case self::STATUT_NON_GEOCODED: return 'Certaines adresses doivent être géocodées';
  119.         }
  120.     }
  121.     public function getStatusBadgeInfo(){
  122.         switch ($this->getStatus())
  123.         {
  124.             case self::STATUT_VIDE: return 'warning';
  125.             case self::STATUT_GEOCODED: return 'success';
  126.             case self::STATUT_NON_GEOCODED: return 'warning';
  127.         }
  128.     }
  129.     /**
  130.      * @return int
  131.      */
  132.     public function getNbAddresses()
  133.     {
  134.        return $this->getAddresses()->count();
  135.     }
  136.     public function getLocked(): ?bool
  137.     {
  138.         return $this->locked;
  139.     }
  140.     public function setLocked(bool $locked): self
  141.     {
  142.         $this->locked $locked;
  143.         return $this;
  144.     }
  145.     public function isGeocoded(){
  146.         if($this->getStatus() == self::STATUT_GEOCODED){
  147.             return true;
  148.         }
  149.         return false;
  150.     }
  151. }