<?php
namespace App\Entity;
use App\Repository\ReserveRepository;
use DateTimeInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Repository\ReserveRepository", repositoryClass=ReserveRepository::class)
*/
class Reserve
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
public function getId(): ?int
{
return $this->id;
}
/**
* @ORM\ManyToOne(targetEntity=Motorcycle::class, inversedBy="reserves")
*/
private $motorcycle;
/**
* @ORM\ManyToOne(targetEntity=Client::class, inversedBy="reserves")
*/
private $client;
/**
* @ORM\Column(type="datetime")
*/
private DateTimeInterface $startDate;
/**
* @ORM\Column(type="datetime")
*/
private DateTimeInterface $endDate;
/**
* @ORM\Column(type="float", nullable=true)
*/
private ?float $amount;
/**
* @var int
*
* @ORM\Column(name="status", type="rent_status_type", nullable=true)
*/
private $status;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $notes;
/**
* @ORM\ManyToMany(targetEntity=Equipment::class)
*/
protected Collection $equipment;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private ?int $startRentMileage;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private ?int $endRentMileage;
/**
* @ORM\ManyToOne(targetEntity=AdmUser::class, inversedBy="reserves")
* @ORM\JoinColumn(nullable=true)
*/
private ?AdmUser $admin;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private DateTimeInterface $createdAt;
public function __construct()
{
$this->equipment = new ArrayCollection();
$this->createdAt = new \DateTime();
}
public function getMotorcycle(): ?Motorcycle
{
return $this->motorcycle;
}
public function setMotorcycle( $motorcycle): void
{
$this->motorcycle = $motorcycle;
}
public function getClient()
{
return $this->client;
}
public function setClient( $client): void
{
$this->client = $client;
}
public function getStartDate(): DateTimeInterface
{
return $this->startDate;
}
public function setStartDate(DateTimeInterface $startDate): void
{
$this->startDate = $startDate;
}
public function getEndDate(): DateTimeInterface
{
if (isset($this->endDate) && $this->endDate->format('s') === '59') {
return $this->endDate->modify('+ 1 second');
}
return $this->endDate;
}
public function setEndDate(DateTimeInterface $endDate): void
{
$this->endDate = $endDate;
}
public function getAmount(): ?float
{
return $this->amount;
}
public function setAmount(float $amount): void
{
$this->amount = $amount;
}
public function getStatus(): int
{
return $this->status;
}
public function setStatus(int $status): void
{
$this->status = $status;
}
public function getNotes(): ?string
{
return $this->notes;
}
public function setNotes(?string $notes): self
{
$this->notes = $notes;
return $this;
}
public function getEquipment(): Collection
{
return $this->equipment;
}
public function addEquipment(Equipment $equipment): void
{
if (!$this->equipment->contains($equipment)) {
$this->equipment->add($equipment);
}
}
public function removeEquipment(Equipment $equipment): void
{
if ($this->equipment->contains($equipment)) {
$this->equipment->removeElement($equipment);
}
}
/**
* @var array<int, Equipment> $equipments
*/
public function setEquipments(array $equipments): void
{
$this->equipment = new ArrayCollection($equipments);
}
public function getStartRentMileage(): ?int
{
return $this->startRentMileage;
}
public function setStartRentMileage(?int $startRentMileage): void
{
$this->startRentMileage = $startRentMileage;
}
public function getEndRentMileage(): ?int
{
return $this->endRentMileage;
}
public function setEndRentMileage(?int $endRentMileage): void
{
$this->endRentMileage = $endRentMileage;
}
public function getAdmin()
{
return $this->admin;
}
public function setAdmin($admin): void
{
$this->admin = $admin;
}
public function getCreatedAt(): DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(DateTimeInterface $createdAt): void
{
$this->createdAt = $createdAt;
}
}