Files
myep-team/src/Entity/Destination.php
T

210 lines
4.3 KiB
PHP

<?php
namespace App\Entity;
use App\BusProNet\Model\Pickup;
use App\Entity\Traits\BlameableEntity;
use App\Entity\Traits\SoftDeletableEntity;
use App\Entity\Traits\TimestampableEntity;
use App\Repository\DestinationRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Entity(repositoryClass: DestinationRepository::class)]
class Destination implements TimestampableEntityInterface, SoftDeletableEntityInterface, BlameableEntityInterface
{
use BlameableEntity;
use TimestampableEntity;
use SoftDeletableEntity;
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(nullable: true)]
private ?int $busProId = null;
#[ORM\Column(length: 32, nullable: true)]
private ?string $code = null;
#[ORM\Column(type: Types::DATE_IMMUTABLE)]
private ?\DateTimeImmutable $dateFrom = null;
#[ORM\Column(type: Types::DATE_IMMUTABLE)]
private ?\DateTimeImmutable $dateTo = null;
#[ORM\Column(length: 255)]
private ?string $product = null;
#[ORM\Column(length: 255)]
private ?string $hotel = null;
#[ORM\Column(length: 32)]
private ?string $hotelCode = null;
#[ORM\Column]
private ?int $hotelBusProId = null;
#[ORM\Column]
private array $pickups = [];
#[ORM\Column(length: 2, nullable: true)]
private ?string $country = null;
public function __toString(): string
{
return sprintf('%s - %s %s',
$this->getDateFrom()->format('d.m.y'),
$this->getDateTo()->format('d.m.y'),
$this->getProduct()
);
}
public function getId(): ?int
{
return $this->id;
}
public function getBusProId(): ?int
{
return $this->busProId;
}
public function setBusProId(int $busProId): static
{
$this->busProId = $busProId;
return $this;
}
public function getDateFrom(): ?\DateTimeImmutable
{
return $this->dateFrom;
}
public function setDateFrom(?\DateTimeImmutable $dateFrom): static
{
$this->dateFrom = $dateFrom;
return $this;
}
public function getDateTo(): ?\DateTimeImmutable
{
return $this->dateTo;
}
public function setDateTo(?\DateTimeImmutable $dateTo): static
{
$this->dateTo = $dateTo;
return $this;
}
public function getCode(): ?string
{
return $this->code;
}
public function setCode(string $code): static
{
$this->code = $code;
return $this;
}
public function getProduct(): ?string
{
return $this->product;
}
public function setProduct(?string $product): static
{
$this->product = $product;
return $this;
}
public function getHotel(): ?string
{
return $this->hotel;
}
public function setHotel(?string $hotel): static
{
$this->hotel = $hotel;
return $this;
}
public function getHotelCode(): ?string
{
return $this->hotelCode;
}
public function setHotelCode(?string $hotelCode): static
{
$this->hotelCode = $hotelCode;
return $this;
}
public function getHotelBusProId(): ?int
{
return $this->hotelBusProId;
}
public function setHotelBusProId(?int $hotelBusProId): static
{
$this->hotelBusProId = $hotelBusProId;
return $this;
}
public function getPickups(): array
{
return $this->pickups;
}
public function setPickups(array $pickups): static
{
$this->pickups = $pickups;
return $this;
}
public function getPickup(?int $id): ?Pickup
{
if (null === $id) {
return null;
}
foreach ($this->getPickups() as $pickup) {
if ($id === $pickup['busProId']) {
return Pickup::fromArray($pickup);
}
}
return null;
}
public function hasBusTransfer(): bool
{
return 0 < count($this->getPickups());
}
public function getCountry(): ?string
{
return $this->country;
}
public function setCountry(?string $country): static
{
$this->country = $country;
return $this;
}
}