src/Entity/Country.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CountryRepository;
  4. use Doctrine\DBAL\Types\Types;;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. #[ORM\Entity(repositoryClassCountryRepository::class)]
  11. #[UniqueEntity(['name'])]
  12. class Country
  13. {
  14.     #[ORM\Id]
  15.     #[ORM\GeneratedValue]
  16.     #[ORM\Column(type'integer')]
  17.     private $id;
  18.     #[ORM\Column(type'string'length64uniquetrue)]
  19.     #[Assert\NotBlank]
  20.     #[Assert\Length(min3max64)]
  21.     #[Assert\Regex(
  22.         pattern'/^[\p{L}\p{M}\s\'-]+$/u',
  23.     )]
  24.     private ?string $name null;
  25.     #[ORM\ManyToOne(targetEntityContinent::class)]
  26.     private ?Continent $continent;
  27.     #[ORM\Column(type'boolean')]
  28.     private bool $active;
  29.     #[ORM\Column(length3nullabletrue)]
  30.     private ?string $currency null;
  31.     #[Assert\NotBlank]
  32.     #[Assert\Positive]
  33.     #[Assert\LessThanOrEqual(value999)]
  34.     #[ORM\Column(typeTypes::SMALLINTnullabletrue)]
  35.     private ?int $prefix null;
  36.     #[Assert\NotBlank]
  37.     #[ORM\Column(length2nullabletrue)]
  38.     private ?string $codeAlpha2 null;
  39.     public function getId()
  40.     {
  41.         return $this->id;
  42.     }
  43.     public function getName(): string
  44.     {
  45.         return $this->name;
  46.     }
  47.     public function setName(?string $name): self
  48.     {
  49.         $this->name $name;
  50.         return $this;
  51.     }
  52.     public function getContinent(): ?Continent
  53.     {
  54.         return $this->continent;
  55.     }
  56.     public function setContinent(Continent $continent): self
  57.     {
  58.         $this->continent $continent;
  59.         return $this;
  60.     }
  61.     public function isActive(): bool
  62.     {
  63.         return $this->active;
  64.     }
  65.     public function setActive(bool $active): self
  66.     {
  67.         $this->active $active;
  68.         return $this;
  69.     }
  70.     public function __toString(): string
  71.     {
  72.         return $this->name;
  73.     }
  74.     public function getCurrency(): string
  75.     {
  76.         return $this->currency;
  77.     }
  78.     public function setCurrency(?string $currency): self
  79.     {
  80.         $this->currency $currency;
  81.         return $this;
  82.     }
  83.     public function getPrefix(): ?int
  84.     {
  85.         return $this->prefix;
  86.     }
  87.     public function setPrefix(?int $prefix): self
  88.     {
  89.         $this->prefix $prefix;
  90.         return $this;
  91.     }
  92.     public function getCodeAlpha2(): ?string
  93.     {
  94.         return $this->codeAlpha2;
  95.     }
  96.     public function setCodeAlpha2(?string $codeAlpha2): static
  97.     {
  98.         $this->codeAlpha2 $codeAlpha2;
  99.         return $this;
  100.     }
  101. }