<?php
namespace App\Entity;
use App\Repository\AgencyRepository;
use App\Trait\GeographicCoordinates;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Entity(repositoryClass: AgencyRepository::class)]
class Agency
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'string', length: 255)]
#[Assert\NotBlank(message: 'This value should not be blank')]
private ?string $name;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Assert\NotBlank]
private ?string $address;
#[ORM\Column(type: Types::STRING,length: 20, nullable: true)]
#[Assert\Regex(pattern: "/^\+?\d{1,3}?[-. ]?\d{7,10}$/")]
private ?string $phone = null;
use GeographicCoordinates;
#[ORM\Column(type: 'boolean')]
private bool $active;
#[ORM\ManyToOne(targetEntity: City::class)]
private ?City $city;
#[ORM\ManyToMany(targetEntity: Personal::class, mappedBy: 'authAgencies')]
private $authPersonals;
#[ORM\Column(length: 3, nullable: true)]
private ?string $currency = null;
#[ORM\Column(nullable: true)]
private ?bool $isDefault = null;
public function __construct()
{
$this->authPersonals = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): self
{
$this->name = $name;
return $this;
}
public function getAddress(): ?string
{
return $this->address;
}
public function setAddress(?string $address): self
{
$this->address = $address;
return $this;
}
public function getPhone(): ?string
{
return $this->phone;
}
public function setPhone(?string $phone): self
{
$this->phone = $phone;
return $this;
}
public function getCity(): ?City
{
return $this->city;
}
public function setCity(?City $city): self
{
$this->city = $city;
return $this;
}
public function isActive(): ?bool
{
return $this->active;
}
public function setActive(bool $active): self
{
$this->active = $active;
return $this;
}
/**
* @return Collection<int, Personal>
*/
public function getAuthPersonals(): Collection
{
return $this->authPersonals;
}
public function addAuthPersonal(Personal $authPersonal): self
{
if (!$this->authPersonals->contains($authPersonal)) {
$this->authPersonals[] = $authPersonal;
$authPersonal->addAuthAgency($this);
}
return $this;
}
public function removeAuthPersonal(Personal $authPersonal): self
{
if ($this->authPersonals->removeElement($authPersonal)) {
$authPersonal->removeAuthAgency($this);
}
return $this;
}
public function __toString(): string
{
return $this->name;
}
public function getCurrency(): ?string
{
return $this->currency;
}
public function setCurrency(?string $currency): self
{
$this->currency = $currency;
return $this;
}
public function isIsDefault(): ?bool
{
return $this->isDefault;
}
public function setIsDefault(?bool $isDefault): self
{
$this->isDefault = $isDefault;
return $this;
}
}