src/Entity/Geolocation.php line 21

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity;
  4. use DateTime;
  5. use Doctrine\ORM\Mapping\Column;
  6. use Doctrine\ORM\Mapping\Entity;
  7. use Doctrine\ORM\Mapping\GeneratedValue;
  8. use Doctrine\ORM\Mapping\HasLifecycleCallbacks;
  9. use Doctrine\ORM\Mapping\Id;
  10. use Doctrine\ORM\Mapping\JoinColumn;
  11. use Doctrine\ORM\Mapping\ManyToOne;
  12. use Doctrine\ORM\Mapping\OneToOne;
  13. use Doctrine\ORM\Mapping\PrePersist;
  14. use Doctrine\ORM\Mapping\PreUpdate;
  15. #[Entity]
  16. #[HasLifecycleCallbacks]
  17. class Geolocation
  18. {
  19.     #[Id]
  20.     #[GeneratedValue]
  21.     #[Column(type'bigint'options: ['unsigned' => true])]
  22.     private ?int $id null;
  23.     #[Column(type'datetime'nullablefalse)]
  24.     private DateTime $createdAt;
  25.     #[Column(type'datetime'nullabletrue)]
  26.     private ?DateTime $updatedAt null;
  27.     public function __construct(
  28.         #[Column(type'string'nullabletrue)]
  29.         private ?string $countryName,
  30.         #[Column(type'string'nullabletrue)]
  31.         private ?string $city,
  32.         #[Column(type'string'nullabletrue)]
  33.         private ?string $street,
  34.         #[Column(type'text'nullabletrue)]
  35.         private ?string $address,
  36.         #[Column(type'float'nullablefalse)]
  37.         private float $latitude,
  38.         #[Column(type'float'nullablefalse)]
  39.         private float $longitude,
  40.         #[ManyToOne(targetEntityCountry::class, cascade: ['persist'])]
  41.         private ?Country $country,
  42.         #[Column(type'boolean'nullablefalse)]
  43.         private bool $active,
  44.     ) {
  45.     }
  46.     #[PrePersist]
  47.     public function prePersist(): void
  48.     {
  49.         $this->createdAt = new DateTime();
  50.     }
  51.     #[PreUpdate]
  52.     public function preUpdate(): void
  53.     {
  54.         $this->updatedAt = new DateTime();
  55.     }
  56.     public function getId(): ?int
  57.     {
  58.         return $this->id;
  59.     }
  60.     public function getCity(): ?string
  61.     {
  62.         return $this->city;
  63.     }
  64.     public function setCity(?string $city): self
  65.     {
  66.         $this->city $city;
  67.         return $this;
  68.     }
  69.     public function getStreet(): ?string
  70.     {
  71.         return $this->street;
  72.     }
  73.     public function setStreet(?string $street): self
  74.     {
  75.         $this->street $street;
  76.         return $this;
  77.     }
  78.     public function getCountryName(): ?string
  79.     {
  80.         return $this->countryName;
  81.     }
  82.     public function setCountryName(?string $countryName): self
  83.     {
  84.         $this->countryName $countryName;
  85.         return $this;
  86.     }
  87.     public function getAddress(): ?string
  88.     {
  89.         return $this->address;
  90.     }
  91.     public function setAddress(?string $address): self
  92.     {
  93.         $this->address $address;
  94.         return $this;
  95.     }
  96.     public function getLatitude(): float
  97.     {
  98.         return $this->latitude;
  99.     }
  100.     public function setLatitude(float $latitude): self
  101.     {
  102.         $this->latitude $latitude;
  103.         return $this;
  104.     }
  105.     public function getLongitude(): float
  106.     {
  107.         return $this->longitude;
  108.     }
  109.     public function setLongitude(float $longitude): self
  110.     {
  111.         $this->longitude $longitude;
  112.         return $this;
  113.     }
  114.     public function getCountry(): ?Country
  115.     {
  116.         return $this->country;
  117.     }
  118.     public function setCountry(?Country $country): self
  119.     {
  120.         $this->country $country;
  121.         return $this;
  122.     }
  123.     public function isActive(): bool
  124.     {
  125.         return $this->active;
  126.     }
  127.     public function setActive(bool $active): self
  128.     {
  129.         $this->active $active;
  130.         return $this;
  131.     }
  132.     public function getCreatedAt(): DateTime
  133.     {
  134.         return $this->createdAt;
  135.     }
  136.     public function getUpdatedAt(): ?DateTime
  137.     {
  138.         return $this->updatedAt;
  139.     }
  140. }