<?php
declare(strict_types=1);
namespace App\Entity;
use DateTime;
use Doctrine\ORM\Mapping\Column;
use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\GeneratedValue;
use Doctrine\ORM\Mapping\HasLifecycleCallbacks;
use Doctrine\ORM\Mapping\Id;
use Doctrine\ORM\Mapping\JoinColumn;
use Doctrine\ORM\Mapping\ManyToOne;
use Doctrine\ORM\Mapping\OneToOne;
use Doctrine\ORM\Mapping\PrePersist;
use Doctrine\ORM\Mapping\PreUpdate;
#[Entity]
#[HasLifecycleCallbacks]
class Geolocation
{
#[Id]
#[GeneratedValue]
#[Column(type: 'bigint', options: ['unsigned' => true])]
private ?int $id = null;
#[Column(type: 'datetime', nullable: false)]
private DateTime $createdAt;
#[Column(type: 'datetime', nullable: true)]
private ?DateTime $updatedAt = null;
public function __construct(
#[Column(type: 'string', nullable: true)]
private ?string $countryName,
#[Column(type: 'string', nullable: true)]
private ?string $city,
#[Column(type: 'string', nullable: true)]
private ?string $street,
#[Column(type: 'text', nullable: true)]
private ?string $address,
#[Column(type: 'float', nullable: false)]
private float $latitude,
#[Column(type: 'float', nullable: false)]
private float $longitude,
#[ManyToOne(targetEntity: Country::class, cascade: ['persist'])]
private ?Country $country,
#[Column(type: 'boolean', nullable: false)]
private bool $active,
) {
}
#[PrePersist]
public function prePersist(): void
{
$this->createdAt = new DateTime();
}
#[PreUpdate]
public function preUpdate(): void
{
$this->updatedAt = new DateTime();
}
public function getId(): ?int
{
return $this->id;
}
public function getCity(): ?string
{
return $this->city;
}
public function setCity(?string $city): self
{
$this->city = $city;
return $this;
}
public function getStreet(): ?string
{
return $this->street;
}
public function setStreet(?string $street): self
{
$this->street = $street;
return $this;
}
public function getCountryName(): ?string
{
return $this->countryName;
}
public function setCountryName(?string $countryName): self
{
$this->countryName = $countryName;
return $this;
}
public function getAddress(): ?string
{
return $this->address;
}
public function setAddress(?string $address): self
{
$this->address = $address;
return $this;
}
public function getLatitude(): float
{
return $this->latitude;
}
public function setLatitude(float $latitude): self
{
$this->latitude = $latitude;
return $this;
}
public function getLongitude(): float
{
return $this->longitude;
}
public function setLongitude(float $longitude): self
{
$this->longitude = $longitude;
return $this;
}
public function getCountry(): ?Country
{
return $this->country;
}
public function setCountry(?Country $country): self
{
$this->country = $country;
return $this;
}
public function isActive(): bool
{
return $this->active;
}
public function setActive(bool $active): self
{
$this->active = $active;
return $this;
}
public function getCreatedAt(): DateTime
{
return $this->createdAt;
}
public function getUpdatedAt(): ?DateTime
{
return $this->updatedAt;
}
}