src/Entity/Reserve.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ReserveRepository;
  4. use DateTimeInterface;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. /**
  9.  * @ORM\Entity(repositoryClass="App\Repository\ReserveRepository", repositoryClass=ReserveRepository::class)
  10.  */
  11. class Reserve
  12. {
  13.     /**
  14.      * @ORM\Id()
  15.      * @ORM\GeneratedValue()
  16.      * @ORM\Column(type="integer")
  17.      */
  18.     private $id;
  19.     public function getId(): ?int
  20.     {
  21.         return $this->id;
  22.     }
  23.     /**
  24.      * @ORM\ManyToOne(targetEntity=Motorcycle::class, inversedBy="reserves")
  25.      */
  26.     private $motorcycle;
  27.     /**
  28.      * @ORM\ManyToOne(targetEntity=Client::class, inversedBy="reserves")
  29.      */
  30.     private $client;
  31.     /**
  32.      * @ORM\Column(type="datetime")
  33.      */
  34.     private DateTimeInterface $startDate;
  35.     /**
  36.      * @ORM\Column(type="datetime")
  37.      */
  38.     private DateTimeInterface $endDate;
  39.     /**
  40.      * @ORM\Column(type="float", nullable=true)
  41.      */
  42.     private ?float $amount;
  43.     /**
  44.      * @var int
  45.      *
  46.      * @ORM\Column(name="status", type="rent_status_type", nullable=true)
  47.      */
  48.     private $status;
  49.     /**
  50.      * @ORM\Column(type="text", nullable=true)
  51.      */
  52.     private $notes;
  53.     /**
  54.      * @ORM\ManyToMany(targetEntity=Equipment::class)
  55.      */
  56.     protected Collection $equipment;
  57.     /**
  58.      * @ORM\Column(type="integer", nullable=true)
  59.      */
  60.     private ?int $startRentMileage;
  61.     /**
  62.      * @ORM\Column(type="integer", nullable=true)
  63.      */
  64.     private ?int $endRentMileage;
  65.     /**
  66.      * @ORM\ManyToOne(targetEntity=AdmUser::class, inversedBy="reserves")
  67.      * @ORM\JoinColumn(nullable=true)
  68.      */
  69.     private ?AdmUser $admin;
  70.     /**
  71.      * @ORM\Column(type="datetime", nullable=true)
  72.      */
  73.     private DateTimeInterface $createdAt;
  74.     public function __construct()
  75.     {
  76.         $this->equipment = new ArrayCollection();
  77.         $this->createdAt = new \DateTime();
  78.     }
  79.     public function getMotorcycle(): ?Motorcycle
  80.     {
  81.         return $this->motorcycle;
  82.     }
  83.     public function setMotorcycle$motorcycle): void
  84.     {
  85.         $this->motorcycle $motorcycle;
  86.     }
  87.     public function getClient()
  88.     {
  89.         return $this->client;
  90.     }
  91.     public function setClient$client): void
  92.     {
  93.         $this->client $client;
  94.     }
  95.     public function getStartDate(): DateTimeInterface
  96.     {
  97.         return $this->startDate;
  98.     }
  99.     public function setStartDate(DateTimeInterface $startDate): void
  100.     {
  101.         $this->startDate $startDate;
  102.     }
  103.     public function getEndDate(): DateTimeInterface
  104.     {
  105.         if (isset($this->endDate) && $this->endDate->format('s') === '59') {
  106.             return $this->endDate->modify('+ 1 second');
  107.         }
  108.         return $this->endDate;
  109.     }
  110.     public function setEndDate(DateTimeInterface $endDate): void
  111.     {
  112.         $this->endDate $endDate;
  113.     }
  114.     public function getAmount(): ?float
  115.     {
  116.         return $this->amount;
  117.     }
  118.     public function setAmount(float $amount): void
  119.     {
  120.         $this->amount $amount;
  121.     }
  122.     public function getStatus(): int
  123.     {
  124.         return $this->status;
  125.     }
  126.     public function setStatus(int $status): void
  127.     {
  128.         $this->status $status;
  129.     }
  130.     public function getNotes(): ?string
  131.     {
  132.         return $this->notes;
  133.     }
  134.     public function setNotes(?string $notes): self
  135.     {
  136.         $this->notes $notes;
  137.         return $this;
  138.     }
  139.     public function getEquipment(): Collection
  140.     {
  141.         return $this->equipment;
  142.     }
  143.     public function addEquipment(Equipment $equipment): void
  144.     {
  145.         if (!$this->equipment->contains($equipment)) {
  146.             $this->equipment->add($equipment);
  147.         }
  148.     }
  149.     public function removeEquipment(Equipment $equipment): void
  150.     {
  151.         if ($this->equipment->contains($equipment)) {
  152.             $this->equipment->removeElement($equipment);
  153.         }
  154.     }
  155.     /**
  156.      * @var array<int, Equipment> $equipments
  157.      */
  158.     public function setEquipments(array $equipments): void
  159.     {
  160.         $this->equipment = new ArrayCollection($equipments);
  161.     }
  162.     public function getStartRentMileage(): ?int
  163.     {
  164.         return $this->startRentMileage;
  165.     }
  166.     public function setStartRentMileage(?int $startRentMileage): void
  167.     {
  168.         $this->startRentMileage $startRentMileage;
  169.     }
  170.     public function getEndRentMileage(): ?int
  171.     {
  172.         return $this->endRentMileage;
  173.     }
  174.     public function setEndRentMileage(?int $endRentMileage): void
  175.     {
  176.         $this->endRentMileage $endRentMileage;
  177.     }
  178.     public function getAdmin()
  179.     {
  180.         return $this->admin;
  181.     }
  182.     public function setAdmin($admin): void
  183.     {
  184.         $this->admin $admin;
  185.     }
  186.     public function getCreatedAt(): DateTimeInterface
  187.     {
  188.         return $this->createdAt;
  189.     }
  190.     public function setCreatedAt(DateTimeInterface $createdAt): void
  191.     {
  192.         $this->createdAt $createdAt;
  193.     }
  194. }