1 | <?php namespace VojtaSvoboda\Reservations\Classes; |
||
12 | class DatesResolver |
||
13 | { |
||
14 | /** |
||
15 | * Returns reserved time slots from non cancelled reservations. |
||
16 | * |
||
17 | * If you have reservations at 13.10.2016 at 11:00 and also at 13:00, both with 2 hours lenght, this method return |
||
18 | * all booked slots - from 09:15 to 14:45 (when you have 15 minutes slot lenght). |
||
19 | * |
||
20 | * ------------ 11:00 ------------- 13:00 -------------- |
||
21 | * |
||
22 | * Because nearest reservation can be done at 09:00 with 2 hours lenghts and next reservation at 15:00. |
||
23 | * |
||
24 | * @param Collection $reservations |
||
25 | * |
||
26 | * @return array |
||
27 | */ |
||
28 | public function getDatesFromReservations(Collection $reservations) |
||
59 | |||
60 | /** |
||
61 | * Get booked interval around the given date. |
||
62 | * |
||
63 | * @param Carbon $date |
||
64 | * |
||
65 | * @return array |
||
66 | */ |
||
67 | public function getBoundaryDates(Carbon $date) |
||
78 | |||
79 | /** |
||
80 | * Get boundary date before reservation date. |
||
81 | * |
||
82 | * @param Carbon $date |
||
83 | * @param string $length |
||
84 | * |
||
85 | * @return mixed |
||
86 | */ |
||
87 | private function getBoundaryBefore(Carbon $date, $length) |
||
95 | |||
96 | /** |
||
97 | * Get boundary date after reservation date. |
||
98 | * |
||
99 | * @param Carbon $date |
||
100 | * @param string $length |
||
101 | * |
||
102 | * @return mixed |
||
103 | */ |
||
104 | private function getBoundaryAfter(Carbon $date, $length) |
||
112 | |||
113 | protected function getDateFormat() |
||
117 | |||
118 | protected function getTimeFormat() |
||
122 | |||
123 | protected function getInterval() |
||
127 | |||
128 | protected function getLength() |
||
132 | } |
||
133 |