| @@ -5,25 +5,25 @@ | ||
| 5 | 5 | |
| 6 | 6 | namespace LatePoint\Misc; |
| 7 | 7 | |
| 8 | 8 | class Filter { |
| 9 | - public $service_id = 0; | |
| 10 | - public $agent_id = 0; | |
| 9 | + public $service_id = 0; | |
| 10 | + public $agent_id = 0; | |
| 11 | 11 | public $location_id = 0; |
| 12 | 12 | |
| 13 | 13 | public $connections = []; |
| 14 | 14 | |
| 15 | - public ?int $week_day = null; | |
| 15 | + public ?int $week_day = null; | |
| 16 | 16 | public ?string $date_from = null; |
| 17 | - public ?string $date_to = null; | |
| 17 | + public ?string $date_to = null; | |
| 18 | 18 | |
| 19 | 19 | public ?int $start_time = null; |
| 20 | - public ?int $end_time = null; | |
| 20 | + public ?int $end_time = null; | |
| 21 | 21 | |
| 22 | - public array $statuses = []; | |
| 22 | + public array $statuses = []; | |
| 23 | 23 | public array $exclude_booking_ids = []; |
| 24 | - public bool $consider_cart_items = false; | |
| 25 | - public bool $exact_match = false; | |
| 24 | + public bool $consider_cart_items = false; | |
| 25 | + public bool $exact_match = false; | |
| 26 | 26 | |
| 27 | 27 | function __construct( array $args = [] ) { |
| 28 | 28 | $allowed_args = [ |
| 29 | 29 | 'service_id', |
| @@ -36,9 +36,9 @@ | ||
| 36 | 36 | 'end_time', |
| 37 | 37 | 'week_day', |
| 38 | 38 | 'statuses', |
| 39 | 39 | 'exclude_booking_ids', |
| 40 | - 'exact_match', | |
| 40 | + 'exact_match' | |
| 41 | 41 | ]; |
| 42 | 42 | foreach ( $args as $key => $arg ) { |
| 43 | 43 | if ( in_array( $key, $allowed_args ) ) { |
| 44 | 44 | $this->$key = $arg; |
| @@ -53,14 +53,12 @@ | ||
| 53 | 53 | // if connections are passed - query by connection |
| 54 | 54 | if ( $this->connections ) { |
| 55 | 55 | $connection_conditions = []; |
| 56 | 56 | foreach ( $this->connections as $connection ) { |
| 57 | - $connection_conditions[] = [ | |
| 58 | - 'AND' => [ | |
| 59 | - 'agent_id' => [ 0, $connection->agent_id ], | |
| 60 | - 'service_id' => [ 0, $connection->service_id ], | |
| 61 | - 'location_id' => [ 0, $connection->location_id ], | |
| 62 | - ], | |
| 57 | + $connection_conditions[] = [ 'AND' => [ 'agent_id' => [ 0, $connection->agent_id ], | |
| 58 | + 'service_id' => [ 0, $connection->service_id ], | |
| 59 | + 'location_id' => [ 0, $connection->location_id ] | |
| 60 | + ] | |
| 63 | 61 | ]; |
| 64 | 62 | } |
| 65 | 63 | $query_args['AND'][] = [ 'OR' => $connection_conditions ]; |
| 66 | 64 | } else { |
| @@ -98,16 +96,15 @@ | ||
| 98 | 96 | return $query_args; |
| 99 | 97 | } |
| 100 | 98 | |
| 101 | 99 | public static function create_from_booking_request( BookingRequest $booking_request ): Filter { |
| 102 | - return new self( | |
| 103 | - [ | |
| 104 | - 'date_from' => $booking_request->start_date, | |
| 105 | - 'start_time' => $booking_request->start_time, | |
| 106 | - 'end_time' => $booking_request->end_time, | |
| 107 | - 'agent_id' => $booking_request->agent_id, | |
| 108 | - 'location_id' => $booking_request->location_id, | |
| 109 | - 'service_id' => $booking_request->service_id, | |
| 110 | - ] | |
| 111 | - ); | |
| 100 | + return new self( [ | |
| 101 | + 'date_from' => $booking_request->start_date, | |
| 102 | + 'start_time' => $booking_request->start_time, | |
| 103 | + 'end_time' => $booking_request->end_time, | |
| 104 | + 'agent_id' => $booking_request->agent_id, | |
| 105 | + 'location_id' => $booking_request->location_id, | |
| 106 | + 'service_id' => $booking_request->service_id | |
| 107 | + ] ); | |
| 112 | 108 | } |
| 109 | + | |
| 113 | 110 | } |