1 | <?php namespace VojtaSvoboda\Reservations\Facades; |
||
27 | class ReservationsFacade |
||
28 | { |
||
29 | /** @var Reservation $reservations */ |
||
30 | private $reservations; |
||
31 | |||
32 | /** @var Status $statuses */ |
||
33 | private $statuses; |
||
34 | |||
35 | /** @var DatesResolver $datesResolver */ |
||
36 | private $datesResolver; |
||
37 | |||
38 | /** @var array $returningUsersCache */ |
||
39 | private $returningUsersCache; |
||
40 | |||
41 | /** @var ReservationMailer $mailer */ |
||
42 | private $mailer; |
||
43 | |||
44 | /** @var ReservationAdminMailer $adminMailer */ |
||
45 | private $adminMailer; |
||
46 | |||
47 | /** |
||
48 | * ReservationsFacade constructor. |
||
49 | * |
||
50 | * @param Reservation $reservations |
||
51 | * @param Status $statuses |
||
52 | * @param DatesResolver $resolver |
||
53 | * @param ReservationMailer $mailer |
||
54 | * @param ReservationAdminMailer $adminMailer |
||
55 | */ |
||
56 | 18 | public function __construct( |
|
66 | |||
67 | /** |
||
68 | * Create and store reservation. |
||
69 | * |
||
70 | * @param array $data |
||
71 | * |
||
72 | * @return Reservation $reservation |
||
73 | * |
||
74 | * @throws ApplicationException |
||
75 | * @throws ValidationException |
||
76 | */ |
||
77 | 10 | public function storeReservation($data) |
|
96 | |||
97 | /** |
||
98 | * Send mail to client and admin. |
||
99 | * |
||
100 | * @param Reservation $reservation |
||
101 | */ |
||
102 | 5 | public function sendMails($reservation) |
|
113 | |||
114 | /** |
||
115 | * Get all reservations. |
||
116 | * |
||
117 | * @return Collection |
||
118 | */ |
||
119 | public function getReservations() |
||
123 | |||
124 | /** |
||
125 | * Get all active (not cancelled) reservations. |
||
126 | * |
||
127 | * @return Collection |
||
128 | */ |
||
129 | public function getActiveReservations() |
||
133 | |||
134 | /** |
||
135 | * Get all reserved time slots. |
||
136 | * |
||
137 | * @return array |
||
138 | */ |
||
139 | public function getReservedDates() |
||
145 | |||
146 | /** |
||
147 | * Get all reservations by given date interval. |
||
148 | * |
||
149 | * @param Carbon $since Date from. |
||
150 | * @param Carbon $till Date to. |
||
151 | * |
||
152 | * @return mixed |
||
153 | */ |
||
154 | public function getReservationsByInterval(Carbon $since, Carbon $till) |
||
158 | |||
159 | /** |
||
160 | * Get reservations count by one email. |
||
161 | * |
||
162 | * @param $email |
||
163 | * |
||
164 | * @return int |
||
165 | */ |
||
166 | 5 | public function getReservationsCountByMail($email) |
|
170 | |||
171 | /** |
||
172 | * Is user returning or not? You have to set this parameter at Backend Reservations setting. |
||
173 | * |
||
174 | * @param $email |
||
175 | * |
||
176 | * @return bool |
||
177 | */ |
||
178 | 1 | public function isUserReturning($email) |
|
204 | |||
205 | /** |
||
206 | * Bulk reservation state change. |
||
207 | * |
||
208 | * @param array $ids |
||
209 | * @param string $ident |
||
210 | */ |
||
211 | public function bulkStateChange($ids, $ident) |
||
231 | |||
232 | /** |
||
233 | * Bulk reservations delete. |
||
234 | * |
||
235 | * @param array $ids |
||
236 | */ |
||
237 | public function bulkDelete($ids) |
||
250 | |||
251 | /** |
||
252 | * Transform date and time to DateTime string. |
||
253 | * |
||
254 | * @param $data |
||
255 | * |
||
256 | * @return Carbon |
||
257 | * |
||
258 | * @throws ApplicationException |
||
259 | */ |
||
260 | 11 | public function transformDateTime($data) |
|
300 | |||
301 | /** |
||
302 | * Get working days. We are starting with sunday, because Carbon dayOfWeek for Sunday is 0. |
||
303 | * |
||
304 | * @return array |
||
305 | */ |
||
306 | 8 | public function getWorkingDays() |
|
320 | |||
321 | /** |
||
322 | * Get working time. |
||
323 | * |
||
324 | * @return array |
||
325 | */ |
||
326 | 7 | public function getWorkingTime() |
|
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 | 12 | public function isDateAvailable($date, $exceptId = null) |
|
364 | |||
365 | /** |
||
366 | * Check reservations amount limit per time. |
||
367 | * |
||
368 | * @throws ApplicationException |
||
369 | */ |
||
370 | 10 | 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 | 10 | public function isCreatedWhileAgo() |
|
393 | } |
||
394 |