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(['name'])]
  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;
  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.     
  37.     public function __construct()
  38.     {
  39.     }
  40.     public function getId(): ?int
  41.     {
  42.         return $this->id;
  43.     }
  44.     public function getName(): ?string
  45.     {
  46.         return $this->name;
  47.     }
  48.     public function setName(?string $name): self
  49.     {
  50.         $this->name $name;
  51.         return $this;
  52.     }
  53.     public function isActive(): ?bool
  54.     {
  55.         return $this->active;
  56.     }
  57.     public function setActive(bool $active): self
  58.     {
  59.         $this->active $active;
  60.         return $this;
  61.     }
  62.     public function __toString(): string
  63.     {
  64.         return  $this->name;
  65.     }
  66.     public function getCountry(): ?Country
  67.     {
  68.         return $this->country;
  69.     }
  70.     public function setCountry(?Country $country): self
  71.     {
  72.         $this->country $country;
  73.         return $this;
  74.     }
  75.     public function getImage(): ?FileData
  76.     {
  77.         return $this->image;
  78.     }
  79.     public function setImage(?FileData $image): static
  80.     {
  81.         $this->image $image;
  82.         return $this;
  83.     }
  84.     public function getDescription(): ?string
  85.     {
  86.         return $this->description;
  87.     }
  88.     public function setDescription(?string $description): static
  89.     {
  90.         $this->description $description;
  91.         return $this;
  92.     }
  93.     public function isStateTransfer(): ?bool
  94.     {
  95.         return $this->stateTransfer;
  96.     }
  97.     public function setStateTransfer(?bool $stateTransfer): static
  98.     {
  99.         $this->stateTransfer $stateTransfer;
  100.         return $this;
  101.     }
  102. }