1 | <?php namespace VojtaSvoboda\Reservations\Classes; |
||
11 | class DatesResolver |
||
12 | { |
||
13 | /** |
||
14 | * Returns reserved time slots from non cancelled reservations. |
||
15 | * |
||
16 | * If you have reservations at 13.10.2016 at 11:00 and also at 13:00, both with 2 hours lenght, this method return |
||
17 | * all booked slots - from 09:15 to 14:45 (when you have 15 minutes slot lenght). |
||
18 | * |
||
19 | * ------------ 11:00 ------------- 13:00 -------------- |
||
20 | * |
||
21 | * Because nearest reservation can be done at 09:00 with 2 hours lenghts and next reservation at 15:00. |
||
22 | * |
||
23 | * @param Collection $reservations |
||
24 | * |
||
25 | * @return array |
||
26 | */ |
||
27 | public function getDatesFromReservations(Collection $reservations) |
||
53 | |||
54 | /** |
||
55 | * Get booked interval around the given date. |
||
56 | * |
||
57 | * @param Carbon $date |
||
58 | * |
||
59 | * @return array |
||
60 | */ |
||
61 | 12 | public function getBoundaryDates(Carbon $date) |
|
72 | |||
73 | /** |
||
74 | * Get boundary date before reservation date. |
||
75 | * |
||
76 | * @param Carbon $date |
||
77 | * @param string $length |
||
78 | * |
||
79 | * @return mixed |
||
80 | */ |
||
81 | 12 | private function getBoundaryBefore(Carbon $date, $length) |
|
89 | |||
90 | /** |
||
91 | * Get boundary date after reservation date. |
||
92 | * |
||
93 | * @param Carbon $date |
||
94 | * @param string $length |
||
95 | * |
||
96 | * @return mixed |
||
97 | */ |
||
98 | 12 | private function getBoundaryAfter(Carbon $date, $length) |
|
106 | |||
107 | /** |
||
108 | * Get reservation imaginary start date. |
||
109 | * |
||
110 | * @param $reservation |
||
111 | * @param $length |
||
112 | * @param $interval |
||
113 | * |
||
114 | * @return mixed |
||
115 | */ |
||
116 | protected function getStartDate($reservation, $length, $interval) |
||
124 | |||
125 | /** |
||
126 | * Get reservation imaginary end date. |
||
127 | * |
||
128 | * @param $reservation |
||
129 | * @param $length |
||
130 | * |
||
131 | * @return mixed |
||
132 | */ |
||
133 | protected function getEndDate($reservation, $length) |
||
140 | |||
141 | /** |
||
142 | * Get date format. |
||
143 | * |
||
144 | * @return string |
||
145 | * |
||
146 | * @deprecated Use Variables::getDateFormat() instead. |
||
147 | */ |
||
148 | protected function getDateFormat() |
||
152 | |||
153 | /** |
||
154 | * Get time format. |
||
155 | * |
||
156 | * @return string |
||
157 | * |
||
158 | * @deprecated Use Variables::getTimeFormat() instead. |
||
159 | */ |
||
160 | protected function getTimeFormat() |
||
164 | |||
165 | /** |
||
166 | * Get reservation interval length. |
||
167 | * |
||
168 | * @return string |
||
169 | * |
||
170 | * @deprecated Use Variables::getReservationInterval() instead. |
||
171 | */ |
||
172 | protected function getInterval() |
||
176 | |||
177 | /** |
||
178 | * Get reservation length. |
||
179 | * |
||
180 | * @return string |
||
181 | * |
||
182 | * @deprecated Use Variables::getReservationLength() instead. |
||
183 | */ |
||
184 | protected function getLength() |
||
188 | } |
||
189 |