pflaenz.li-Symfony/src/Entity/Offer.php

178 lines
3.2 KiB
PHP

<?php
namespace App\Entity;
use App\Repository\OfferRepository;
use Doctrine\ORM\Mapping as ORM;
use Location\Coordinate;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass=OfferRepository::class)
*/
class Offer
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="offers")
* @ORM\JoinColumn(nullable=false)
*/
private $byUser;
/**
* @ORM\Column(type="datetime")
*/
private $createdAt;
/**
* @ORM\Column(type="string", length=255)
*/
#[Assert\NotBlank]
private $title;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $photoFilename;
/**
* @ORM\Column(type="integer")
*/
#[Assert\Length(4)]
private $zipCode;
/**
* @ORM\Column(type="text")
*/
private $description;
/**
* @ORM\Column(type="float", nullable=true)
*/
private $lat;
/**
* @ORM\Column(type="float", nullable=true)
*/
private $lng;
/**
* @ORM\Column(type="string", length=13)
*/
private $urlId;
public function getId(): ?int
{
return $this->id;
}
public function getByUser(): ?User
{
return $this->byUser;
}
public function setByUser(?User $byUser): self
{
$this->byUser = $byUser;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(string $title): self
{
$this->title = $title;
return $this;
}
public function getPhotoFilename(): ?string
{
return $this->photoFilename;
}
public function setPhotoFilename(?string $photoFilename): self
{
$this->photoFilename = $photoFilename;
return $this;
}
public function getZipCode(): ?int
{
return $this->zipCode;
}
public function setZipCode(int $zipCode): self
{
$this->zipCode = $zipCode;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(string $description): self
{
$this->description = $description;
return $this;
}
public function __toString(): string
{
return (string) $this-getTitle();
}
public function getCoordinate(): ?Coordinate
{
$coordinate = new Coordinate($this->lat, $this->lng);
return $coordinate;
}
public function setCoordinate(Coordinate $coordinate): self
{
$this->lat = $coordinate->getLat();
$this->lng = $coordinate->getLng();
return $this;
}
public function getUrlId(): ?string
{
return $this->urlId;
}
public function setUrlId(string $urlId): self
{
$this->urlId = $urlId;
return $this;
}
}