src/Entity/City.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CityRepository;
  4. use App\Trait\GeographicCoordinates;
  5. use Doctrine\DBAL\Types\Types;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  8. use Symfony\Component\Validator\Constraints as Assert;
  9. #[ORM\Entity(repositoryClassCityRepository::class)]
  10. #[UniqueEntity(['externalId'])]
  11. class City
  12. {
  13.     use GeographicCoordinates;
  14.     #[ORM\Id]
  15.     #[ORM\GeneratedValue]
  16.     #[ORM\Column(type'integer')]
  17.     private $id;
  18.     #[ORM\Column(type'string'length50)]
  19.     #[Assert\NotBlank]
  20.     #[Assert\Length(min3max50)]
  21.     #[Assert\Regex(
  22.         pattern'/^[\p{L}\p{M}\s\'-]+$/u',
  23.     )]
  24.     private ?string $name;
  25.     #[ORM\Column(type'boolean')]
  26.     private bool $active false;
  27.     #[ORM\ManyToOne(targetEntityCountry::class)]
  28.     #[ORM\JoinColumn(nullablefalse)]
  29.     private ?Country $country null;
  30.     #[ORM\OneToOne(cascade: ['persist''remove'])]
  31.     private ?FileData $image null;
  32.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  33.     private ?string $description null;
  34.     #[ORM\Column(nullabletrue)]
  35.     private ?bool $stateTransfer null;
  36.     #[ORM\Column(nullabletrue)]
  37.     private ?int $externalId null;
  38.     
  39.     public function __construct()
  40.     {
  41.     }
  42.     public function getId(): ?int
  43.     {
  44.         return $this->id;
  45.     }
  46.     public function getName(): ?string
  47.     {
  48.         return $this->name;
  49.     }
  50.     public function setName(?string $name): self
  51.     {
  52.         $this->name $name;
  53.         return $this;
  54.     }
  55.     public function isActive(): ?bool
  56.     {
  57.         return $this->active;
  58.     }
  59.     public function setActive(bool $active): self
  60.     {
  61.         $this->active $active;
  62.         return $this;
  63.     }
  64.     public function __toString(): string
  65.     {
  66.         return  $this->name;
  67.     }
  68.     public function getCountry(): ?Country
  69.     {
  70.         return $this->country;
  71.     }
  72.     public function setCountry(?Country $country): self
  73.     {
  74.         $this->country $country;
  75.         return $this;
  76.     }
  77.     public function getImage(): ?FileData
  78.     {
  79.         return $this->image;
  80.     }
  81.     public function setImage(?FileData $image): static
  82.     {
  83.         $this->image $image;
  84.         return $this;
  85.     }
  86.     public function getDescription(): ?string
  87.     {
  88.         return $this->description;
  89.     }
  90.     public function setDescription(?string $description): static
  91.     {
  92.         $this->description $description;
  93.         return $this;
  94.     }
  95.     public function isStateTransfer(): ?bool
  96.     {
  97.         return $this->stateTransfer;
  98.     }
  99.     public function setStateTransfer(?bool $stateTransfer): static
  100.     {
  101.         $this->stateTransfer $stateTransfer;
  102.         return $this;
  103.     }
  104.     public function getExternalId(): ?int
  105.     {
  106.         return $this->externalId;
  107.     }
  108.     public function setExternalId(?int $externalId): static
  109.     {
  110.         $this->externalId $externalId;
  111.         return $this;
  112.     }
  113. }