src/Entity/Agency.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\AgencyRepository;
  4. use App\Trait\GeographicCoordinates;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\DBAL\Types\Types;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. #[ORM\Entity(repositoryClass: AgencyRepository::class)]
  11. class Agency
  12. {
  13.     #[ORM\Id]
  14.     #[ORM\GeneratedValue]
  15.     #[ORM\Column(type: 'integer')]
  16.     private $id;
  17.     #[ORM\Column(type: 'string', length: 255)]
  18.     #[Assert\NotBlank(message: 'This value should not be blank')]
  19.     private ?string $name;
  20.     #[ORM\Column(type: 'string', length: 255, nullable: true)]
  21.     #[Assert\NotBlank]
  22.     private ?string $address;
  23.     #[ORM\Column(type: Types::STRING,length: 20, nullable: true)]
  24.     #[Assert\Regex(pattern: "/^\+?\d{1,3}?[-. ]?\d{7,10}$/")]
  25.     private ?string $phone = null;
  26.     use GeographicCoordinates;
  27.     #[ORM\Column(type: 'boolean')]
  28.     private bool $active;
  29.     #[ORM\ManyToOne(targetEntity: City::class)]
  30.     private ?City $city;
  31.     #[ORM\ManyToMany(targetEntity: Personal::class, mappedBy: 'authAgencies')]
  32.     private $authPersonals;
  33.     #[ORM\Column(length: 3, nullable: true)]
  34.     private ?string $currency = null;
  35.     #[ORM\Column(nullable: true)]
  36.     private ?bool $isDefault = null;
  37.     #[ORM\Column(nullable: true)]
  38.     private ?bool $isFranchise = null;
  39.     public function __construct()
  40.     {
  41.         $this->authPersonals = new ArrayCollection();
  42.     }
  43.     public function getId(): ?int
  44.     {
  45.         return $this->id;
  46.     }
  47.     public function getName(): ?string
  48.     {
  49.         return $this->name;
  50.     }
  51.     public function setName(?string $name): self
  52.     {
  53.         $this->name = $name;
  54.         return $this;
  55.     }
  56.     public function getAddress(): ?string
  57.     {
  58.         return $this->address;
  59.     }
  60.     public function setAddress(?string $address): self
  61.     {
  62.         $this->address = $address;
  63.         return $this;
  64.     }
  65.     public function getPhone(): ?string
  66.     {
  67.         return $this->phone;
  68.     }
  69.     public function setPhone(?string $phone): self
  70.     {
  71.         $this->phone = $phone;
  72.         return $this;
  73.     }
  74.     public function getCity(): ?City
  75.     {
  76.         return $this->city;
  77.     }
  78.     public function setCity(?City $city): self
  79.     {
  80.         $this->city = $city;
  81.         return $this;
  82.     }
  83.     public function isActive(): ?bool
  84.     {
  85.         return $this->active;
  86.     }
  87.     public function setActive(bool $active): self
  88.     {
  89.         $this->active = $active;
  90.         return $this;
  91.     }
  92.     /**
  93.      * @return Collection<int, Personal>
  94.      */
  95.     public function getAuthPersonals(): Collection
  96.     {
  97.         return $this->authPersonals;
  98.     }
  99.     public function addAuthPersonal(Personal $authPersonal): self
  100.     {
  101.         if (!$this->authPersonals->contains($authPersonal)) {
  102.             $this->authPersonals[] = $authPersonal;
  103.             $authPersonal->addAuthAgency($this);
  104.         }
  105.         return $this;
  106.     }
  107.     public function removeAuthPersonal(Personal $authPersonal): self
  108.     {
  109.         if ($this->authPersonals->removeElement($authPersonal)) {
  110.             $authPersonal->removeAuthAgency($this);
  111.         }
  112.         return $this;
  113.     }
  114.     public function __toString(): string
  115.     {
  116.         return $this->name;
  117.     }
  118.     public function getCurrency(): ?string
  119.     {
  120.         return $this->currency;
  121.     }
  122.     public function setCurrency(?string $currency): self
  123.     {
  124.         $this->currency = $currency;
  125.         return $this;
  126.     }
  127.     public function isIsDefault(): ?bool
  128.     {
  129.         return $this->isDefault;
  130.     }
  131.     public function setIsDefault(?bool $isDefault): self
  132.     {
  133.         $this->isDefault = $isDefault;
  134.         return $this;
  135.     }
  136.     public function getIsFranchise(): ?bool
  137.     {
  138.         return $this->isFranchise;
  139.     }
  140.     public function setIsFranchise(?bool $isFranchise): void
  141.     {
  142.         $this->isFranchise = $isFranchise;
  143.     }
  144. }