1 | <?php namespace VojtaSvoboda\Reservations\Classes; |
||
13 | class DatesResolver |
||
14 | { |
||
15 | /** |
||
16 | * Returns reserved time slots from non cancelled reservations. |
||
17 | * |
||
18 | * If you have reservations at 13.10.2016 at 11:00 and also at 13:00, both with 2 hours lenght, this method return |
||
19 | * all booked slots - from 09:15 to 14:45 (when you have 15 minutes slot lenght). |
||
20 | * |
||
21 | * ------------ 11:00 ------------- 13:00 -------------- |
||
22 | * |
||
23 | * Because nearest reservation can be done at 09:00 with 2 hours lenghts and next reservation at 15:00. |
||
24 | * |
||
25 | * @param Collection $reservations |
||
26 | * |
||
27 | * @return array |
||
28 | */ |
||
29 | public function getDatesFromReservations(Collection $reservations) |
||
54 | |||
55 | /** |
||
56 | * Get booked interval around the given date. |
||
57 | * |
||
58 | * @param Carbon $date |
||
59 | * |
||
60 | * @return array |
||
61 | */ |
||
62 | public function getBoundaryDates(Carbon $date) |
||
73 | |||
74 | /** |
||
75 | * Get boundary date before reservation date. |
||
76 | * |
||
77 | * @param Carbon $date |
||
78 | * @param string $length |
||
79 | * |
||
80 | * @return mixed |
||
81 | */ |
||
82 | private function getBoundaryBefore(Carbon $date, $length) |
||
90 | |||
91 | /** |
||
92 | * Get boundary date after reservation date. |
||
93 | * |
||
94 | * @param Carbon $date |
||
95 | * @param string $length |
||
96 | * |
||
97 | * @return mixed |
||
98 | */ |
||
99 | private function getBoundaryAfter(Carbon $date, $length) |
||
107 | |||
108 | /** |
||
109 | * Get reservation imaginary start date. |
||
110 | * |
||
111 | * @param $reservation |
||
112 | * @param $length |
||
113 | * @param $interval |
||
114 | * |
||
115 | * @return mixed |
||
116 | */ |
||
117 | protected function getStartDate($reservation, $length, $interval) |
||
125 | |||
126 | /** |
||
127 | * Get reservation imaginary end date. |
||
128 | * |
||
129 | * @param $reservation |
||
130 | * @param $length |
||
131 | * |
||
132 | * @return mixed |
||
133 | */ |
||
134 | protected function getEndDate($reservation, $length) |
||
141 | |||
142 | protected function getDateFormat() |
||
149 | |||
150 | protected function getTimeFormat() |
||
157 | |||
158 | 11 | protected function getInterval() |
|
165 | |||
166 | protected function getLength() |
||
173 | } |
||
174 |