1 | <?php namespace VojtaSvoboda\Reservations\Facades; |
||
25 | class ReservationsFacade |
||
26 | { |
||
27 | /** @var Reservation $reservations */ |
||
28 | private $reservations; |
||
29 | |||
30 | /** @var Status $statuses */ |
||
31 | private $statuses; |
||
32 | |||
33 | /** @var DatesResolver $datesResolver */ |
||
34 | private $datesResolver; |
||
35 | |||
36 | /** @var array $returningUsersCache */ |
||
37 | private $returningUsersCache; |
||
38 | |||
39 | /** @var ReservationMailer $mailer */ |
||
40 | private $mailer; |
||
41 | |||
42 | /** @var ReservationAdminMailer $adminMailer */ |
||
43 | private $adminMailer; |
||
44 | |||
45 | /** |
||
46 | * ReservationsFacade constructor. |
||
47 | * |
||
48 | * @param Reservation $reservations |
||
49 | * @param Status $statuses |
||
50 | * @param DatesResolver $resolver |
||
51 | * @param ReservationMailer $mailer |
||
52 | * @param ReservationAdminMailer $adminMailer |
||
53 | */ |
||
54 | 14 | public function __construct( |
|
64 | |||
65 | /** |
||
66 | * Create and store reservation. |
||
67 | * |
||
68 | * @param array $data |
||
69 | * |
||
70 | * @return Reservation $reservation |
||
71 | * |
||
72 | * @throws ApplicationException |
||
73 | * @throws ValidationException |
||
74 | */ |
||
75 | 7 | public function storeReservation($data) |
|
94 | |||
95 | /** |
||
96 | * Send mail to client and admin. |
||
97 | * |
||
98 | * @param Reservation $reservation |
||
99 | */ |
||
100 | 5 | public function sendMails($reservation) |
|
111 | |||
112 | /** |
||
113 | * Get all reservations. |
||
114 | * |
||
115 | * @return Collection |
||
116 | */ |
||
117 | public function getReservations() |
||
121 | |||
122 | /** |
||
123 | * Get all active (not cancelled) reservations. |
||
124 | * |
||
125 | * @return Collection |
||
126 | */ |
||
127 | public function getActiveReservations() |
||
131 | |||
132 | /** |
||
133 | * Get all reserved time slots. |
||
134 | * |
||
135 | * @return array |
||
136 | */ |
||
137 | public function getReservedDates() |
||
143 | |||
144 | /** |
||
145 | * Get all reservations by given date interval. |
||
146 | * |
||
147 | * @param Carbon $since Date from. |
||
148 | * @param Carbon $till Date to. |
||
149 | * |
||
150 | * @return mixed |
||
151 | */ |
||
152 | public function getReservationsByInterval(Carbon $since, Carbon $till) |
||
156 | |||
157 | /** |
||
158 | * Get reservations count by one email. |
||
159 | * |
||
160 | * @param $email |
||
161 | * |
||
162 | * @return int |
||
163 | */ |
||
164 | 5 | public function getReservationsCountByMail($email) |
|
168 | |||
169 | /** |
||
170 | * Is user returning or not? You have to set this parameter at Backend Reservations setting. |
||
171 | * |
||
172 | * @param $email |
||
173 | * |
||
174 | * @return bool |
||
175 | */ |
||
176 | 1 | public function isUserReturning($email) |
|
202 | |||
203 | /** |
||
204 | * Bulk reservation state change. |
||
205 | * |
||
206 | * @param array $ids |
||
207 | * @param string $ident |
||
208 | */ |
||
209 | public function bulkStateChange($ids, $ident) |
||
229 | |||
230 | /** |
||
231 | * Bulk reservations delete. |
||
232 | * |
||
233 | * @param array $ids |
||
234 | */ |
||
235 | public function bulkDelete($ids) |
||
248 | |||
249 | /** |
||
250 | * Transform date and time to DateTime string. |
||
251 | * |
||
252 | * @param $data |
||
253 | * |
||
254 | * @return Carbon |
||
255 | * |
||
256 | * @throws ApplicationException |
||
257 | */ |
||
258 | 8 | public function transformDateTime($data) |
|
274 | |||
275 | /** |
||
276 | * Returns if given date is available. |
||
277 | * |
||
278 | * @param Carbon $date |
||
279 | * @param int $exceptId Except reservation ID. |
||
280 | * |
||
281 | * @return bool |
||
282 | */ |
||
283 | 11 | public function isDateAvailable($date, $exceptId = null) |
|
298 | |||
299 | /** |
||
300 | * Check reservations amount limit per time. |
||
301 | * |
||
302 | * @throws ApplicationException |
||
303 | */ |
||
304 | 7 | private function checkLimits() |
|
310 | |||
311 | /** |
||
312 | * Try to find some reservation in less then given limit (default 30 seconds). |
||
313 | * |
||
314 | * @return boolean |
||
315 | */ |
||
316 | 7 | public function isCreatedWhileAgo() |
|
327 | } |
||
328 |