blocked_period.php
1 year ago
booked_period.php
1 year ago
booking_request.php
1 year ago
booking_resource.php
1 year ago
booking_slot.php
1 year ago
filter.php
1 year ago
process_action.php
1 year ago
process_event.php
1 year ago
role.php
1 year ago
router.php
1 year ago
step.php
1 year ago
stripe_connect_customer.php
1 year ago
time_period.php
1 year ago
user.php
1 year ago
work_period.php
1 year ago
filter.php
57 lines
| 1 | <?php |
| 2 | /* |
| 3 | * Copyright (c) 2021 LatePoint LLC. All rights reserved. |
| 4 | */ |
| 5 | |
| 6 | namespace LatePoint\Misc; |
| 7 | |
| 8 | class Filter{ |
| 9 | public $service_id = 0; |
| 10 | public $agent_id = 0; |
| 11 | public $location_id = 0; |
| 12 | |
| 13 | public $connections = []; |
| 14 | |
| 15 | public ?int $week_day = null; |
| 16 | public ?string $date_from = null; |
| 17 | public ?string $date_to = null; |
| 18 | |
| 19 | public ?int $start_time = null; |
| 20 | public ?int $end_time = null; |
| 21 | |
| 22 | public array $statuses = []; |
| 23 | public array $exclude_booking_ids = []; |
| 24 | public bool $consider_cart_items = false; |
| 25 | public bool $exact_match = false; |
| 26 | public int $timeshift_minutes = 0; |
| 27 | |
| 28 | function __construct(array $args = []){ |
| 29 | $allowed_args = [ 'service_id', |
| 30 | 'agent_id', |
| 31 | 'location_id', |
| 32 | 'connections', |
| 33 | 'date_from', |
| 34 | 'date_to', |
| 35 | 'start_time', |
| 36 | 'end_time', |
| 37 | 'week_day', |
| 38 | 'statuses', |
| 39 | 'exclude_booking_ids', |
| 40 | 'timeshift_minutes', |
| 41 | 'exact_match']; |
| 42 | foreach($args as $key => $arg){ |
| 43 | if(in_array($key, $allowed_args)) $this->$key = $arg; |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | public static function create_from_booking_request(BookingRequest $booking_request): Filter{ |
| 48 | return new self([ 'date_from' => $booking_request->start_date, |
| 49 | 'start_time' => $booking_request->start_time, |
| 50 | 'end_time' => $booking_request->end_time, |
| 51 | 'agent_id' => $booking_request->agent_id, |
| 52 | 'location_id' => $booking_request->location_id, |
| 53 | 'service_id' => $booking_request->service_id]); |
| 54 | } |
| 55 | |
| 56 | } |
| 57 |