Generate coordinates when offer added

This commit is contained in:
Jannis Portmann 2022-01-12 14:42:02 +01:00
parent 3a525f397c
commit c6eadf742c
3 changed files with 64 additions and 2 deletions

View file

@ -4,6 +4,7 @@ namespace App\Entity;
use App\Repository\OfferingRepository;
use Doctrine\ORM\Mapping as ORM;
use Location\Coordinate;
use Symfony\Component\Validator\Constraints as Assert;
/**
@ -51,6 +52,16 @@ class Offering
*/
private $description;
/**
* @ORM\Column(type="float", nullable=true)
*/
private $lat;
/**
* @ORM\Column(type="float", nullable=true)
*/
private $lng;
public function getId(): ?int
{
return $this->id;
@ -132,4 +143,19 @@ class Offering
{
return (string) $this-getTitle();
}
}
public function getCoordinate(): ?Coordinate
{
$coordinate = new Coordinate($this->long, $this->lat);
return $coordinate;
}
public function setCoordinate(Coordinate $coordinate): self
{
$this->lat = $coordinate->getLat();
$this->lng = $coordinate->getLng();
return $this;
}
}