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

178 lines
3.2 KiB
PHP
Raw Normal View History

2021-04-24 17:36:38 +02:00
<?php
namespace App\Entity;
2022-01-19 19:59:35 +01:00
use App\Repository\OfferRepository;
2021-04-24 17:36:38 +02:00
use Doctrine\ORM\Mapping as ORM;
2022-01-12 14:42:02 +01:00
use Location\Coordinate;
2021-04-30 17:08:34 +02:00
use Symfony\Component\Validator\Constraints as Assert;
2021-04-24 17:36:38 +02:00
/**
2022-01-19 19:59:35 +01:00
* @ORM\Entity(repositoryClass=OfferRepository::class)
2021-04-24 17:36:38 +02:00
*/
2022-01-19 19:59:35 +01:00
class Offer
2021-04-24 17:36:38 +02:00
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
2022-01-19 19:59:35 +01:00
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="offers")
2021-04-24 17:36:38 +02:00
* @ORM\JoinColumn(nullable=false)
*/
private $byUser;
/**
* @ORM\Column(type="datetime")
*/
private $createdAt;
/**
* @ORM\Column(type="string", length=255)
*/
2021-04-30 17:08:34 +02:00
#[Assert\NotBlank]
2021-04-24 17:36:38 +02:00
private $title;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $photoFilename;
/**
* @ORM\Column(type="integer")
*/
2021-05-06 13:31:06 +02:00
#[Assert\Length(4)]
private $zipCode;
/**
* @ORM\Column(type="text")
*/
private $description;
2022-01-12 14:42:02 +01:00
/**
* @ORM\Column(type="float", nullable=true)
*/
private $lat;
/**
* @ORM\Column(type="float", nullable=true)
*/
private $lng;
2022-01-17 19:11:00 +01:00
/**
* @ORM\Column(type="string", length=13)
*/
private $urlId;
2021-04-24 17:36:38 +02:00
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;
}
2021-05-01 15:33:45 +02:00
public function __toString(): string
{
2022-01-17 19:11:00 +01:00
return (string) $this-getTitle();
2021-05-01 15:33:45 +02:00
}
2022-01-12 14:42:02 +01:00
public function getCoordinate(): ?Coordinate
{
2022-01-12 23:28:25 +01:00
$coordinate = new Coordinate($this->lat, $this->lng);
2022-01-12 14:42:02 +01:00
return $coordinate;
}
public function setCoordinate(Coordinate $coordinate): self
{
$this->lat = $coordinate->getLat();
$this->lng = $coordinate->getLng();
return $this;
}
2022-01-17 19:11:00 +01:00
public function getUrlId(): ?string
{
return $this->urlId;
}
public function setUrlId(string $urlId): self
{
$this->urlId = $urlId;
return $this;
}
2022-01-12 14:42:02 +01:00
}