1 | <?php namespace VojtaSvoboda\Reservations\Facades; |
||
26 | class ReservationsFacade |
||
27 | { |
||
28 | /** @var Reservation $reservations */ |
||
29 | private $reservations; |
||
30 | |||
31 | /** @var Status $statuses */ |
||
32 | private $statuses; |
||
33 | |||
34 | /** @var DatesResolver $datesResolver */ |
||
35 | private $datesResolver; |
||
36 | |||
37 | /** @var array $returningUsersCache */ |
||
38 | private $returningUsersCache; |
||
39 | |||
40 | /** @var ReservationMailer $mailer */ |
||
41 | private $mailer; |
||
42 | |||
43 | /** @var ReservationAdminMailer $adminMailer */ |
||
44 | private $adminMailer; |
||
45 | |||
46 | /** |
||
47 | * ReservationsFacade constructor. |
||
48 | * |
||
49 | * @param Reservation $reservations |
||
50 | * @param Status $statuses |
||
51 | * @param DatesResolver $resolver |
||
52 | * @param ReservationMailer $mailer |
||
53 | * @param ReservationAdminMailer $adminMailer |
||
54 | 14 | */ |
|
55 | public function __construct( |
||
65 | |||
66 | /** |
||
67 | * Create and store reservation. |
||
68 | * |
||
69 | * @param array $data |
||
70 | * |
||
71 | * @return Reservation $reservation |
||
72 | * |
||
73 | * @throws ApplicationException |
||
74 | * @throws ValidationException |
||
75 | 7 | */ |
|
76 | public function storeReservation($data) |
||
95 | |||
96 | /** |
||
97 | * Send mail to client and admin. |
||
98 | * |
||
99 | * @param Reservation $reservation |
||
100 | 5 | */ |
|
101 | public function sendMails($reservation) |
||
112 | |||
113 | /** |
||
114 | * Get all reservations. |
||
115 | * |
||
116 | * @return Collection |
||
117 | */ |
||
118 | public function getReservations() |
||
122 | |||
123 | /** |
||
124 | * Get all active (not cancelled) reservations. |
||
125 | * |
||
126 | * @return Collection |
||
127 | */ |
||
128 | public function getActiveReservations() |
||
132 | |||
133 | /** |
||
134 | * Get all reserved time slots. |
||
135 | * |
||
136 | * @return array |
||
137 | */ |
||
138 | public function getReservedDates() |
||
144 | |||
145 | /** |
||
146 | * Get all reservations by given date interval. |
||
147 | * |
||
148 | * @param Carbon $since Date from. |
||
149 | * @param Carbon $till Date to. |
||
150 | * |
||
151 | * @return mixed |
||
152 | */ |
||
153 | public function getReservationsByInterval(Carbon $since, Carbon $till) |
||
157 | |||
158 | /** |
||
159 | * Get reservations count by one email. |
||
160 | * |
||
161 | * @param $email |
||
162 | * |
||
163 | * @return int |
||
164 | 5 | */ |
|
165 | public function getReservationsCountByMail($email) |
||
169 | |||
170 | /** |
||
171 | * Is user returning or not? You have to set this parameter at Backend Reservations setting. |
||
172 | * |
||
173 | * @param $email |
||
174 | * |
||
175 | * @return bool |
||
176 | 1 | */ |
|
177 | public function isUserReturning($email) |
||
203 | |||
204 | /** |
||
205 | * Bulk reservation state change. |
||
206 | * |
||
207 | * @param array $ids |
||
208 | * @param string $ident |
||
209 | */ |
||
210 | public function bulkStateChange($ids, $ident) |
||
230 | |||
231 | /** |
||
232 | * Bulk reservations delete. |
||
233 | * |
||
234 | * @param array $ids |
||
235 | */ |
||
236 | public function bulkDelete($ids) |
||
249 | |||
250 | /** |
||
251 | * Transform date and time to DateTime string. |
||
252 | * |
||
253 | * @param $data |
||
254 | * |
||
255 | * @return Carbon |
||
256 | * |
||
257 | * @throws ApplicationException |
||
258 | 8 | */ |
|
259 | public function transformDateTime($data) |
||
301 | |||
302 | /** |
||
303 | * Get work days of week |
||
304 | 7 | * |
|
305 | * @return array |
||
306 | 7 | */ |
|
307 | 1 | public function getWorkDays() |
|
320 | 7 | ||
321 | /** |
||
322 | * Get work time of day |
||
323 | 7 | * |
|
324 | * @return array |
||
325 | 7 | */ |
|
326 | public function getWorkTime() |
||
340 | |||
341 | /** |
||
342 | * Returns if given date is available. |
||
343 | * |
||
344 | * @param Carbon $date |
||
345 | * @param int $exceptId Except reservation ID. |
||
346 | * |
||
347 | * @return bool |
||
348 | */ |
||
349 | public function isDateAvailable($date, $exceptId = null) |
||
364 | |||
365 | /** |
||
366 | * Check reservations amount limit per time. |
||
367 | * |
||
368 | * @throws ApplicationException |
||
369 | */ |
||
370 | private function checkLimits() |
||
376 | |||
377 | /** |
||
378 | * Try to find some reservation in less then given limit (default 30 seconds). |
||
379 | * |
||
380 | * @return boolean |
||
381 | */ |
||
382 | public function isCreatedWhileAgo() |
||
393 | } |
||
394 |