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) |
||
55 | |||
56 | /** |
||
57 | * Get booked interval around the given date. |
||
58 | * |
||
59 | * @param Carbon $date |
||
60 | * |
||
61 | * @return array |
||
62 | */ |
||
63 | 11 | public function getBoundaryDates(Carbon $date) |
|
74 | |||
75 | /** |
||
76 | * Get boundary date before reservation date. |
||
77 | * |
||
78 | * @param Carbon $date |
||
79 | * @param string $length |
||
80 | * |
||
81 | * @return mixed |
||
82 | */ |
||
83 | 11 | private function getBoundaryBefore(Carbon $date, $length) |
|
91 | |||
92 | /** |
||
93 | * Get boundary date after reservation date. |
||
94 | * |
||
95 | * @param Carbon $date |
||
96 | * @param string $length |
||
97 | * |
||
98 | * @return mixed |
||
99 | */ |
||
100 | 11 | private function getBoundaryAfter(Carbon $date, $length) |
|
108 | |||
109 | /** |
||
110 | * Get reservation imaginary start date. |
||
111 | * |
||
112 | * @param $reservation |
||
113 | * @param $length |
||
114 | * @param $interval |
||
115 | * |
||
116 | * @return mixed |
||
117 | */ |
||
118 | protected function getStartDate($reservation, $length, $interval) |
||
126 | |||
127 | /** |
||
128 | * Get reservation imaginary end date. |
||
129 | * |
||
130 | * @param $reservation |
||
131 | * @param $length |
||
132 | * |
||
133 | * @return mixed |
||
134 | */ |
||
135 | protected function getEndDate($reservation, $length) |
||
142 | |||
143 | protected function getDateFormat() |
||
147 | |||
148 | protected function getTimeFormat() |
||
152 | |||
153 | protected function getInterval() |
||
157 | |||
158 | 11 | protected function getLength() |
|
162 | } |
||
163 |