diff --git a/application/controllers/api/v1/Appointments_api_v1.php b/application/controllers/api/v1/Appointments_api_v1.php index 097e2471..9b433e4f 100644 --- a/application/controllers/api/v1/Appointments_api_v1.php +++ b/application/controllers/api/v1/Appointments_api_v1.php @@ -58,8 +58,37 @@ class Appointments_api_v1 extends EA_Controller { $with = $this->api->request_with(); + $where = NULL; + + // Date query param. + + $date = request('date'); + + if ( ! empty($date)) + { + $where['DATE(start_datetime)'] = (new DateTime($date))->format('Y-m-d'); + } + + // From query param. + + $from = request('from'); + + if ( ! empty($from)) + { + $where['DATE(start_datetime) >='] = (new DateTime($from))->format('Y-m-d'); + } + + // Till query param. + + $till = request('till'); + + if ( ! empty($till)) + { + $where['DATE(end_datetime) <='] = (new DateTime($till))->format('Y-m-d'); + } + $appointments = empty($keyword) - ? $this->appointments_model->get(NULL, $limit, $offset, $order_by) + ? $this->appointments_model->get($where, $limit, $offset, $order_by) : $this->appointments_model->search($keyword, $limit, $offset, $order_by); foreach ($appointments as &$appointment) @@ -97,7 +126,7 @@ class Appointments_api_v1 extends EA_Controller { try { $fields = $this->api->request_fields(); - + $with = $this->api->request_with(); $appointment = $this->appointments_model->find($id); diff --git a/openapi.yml b/openapi.yml index 34a2a320..74476002 100644 --- a/openapi.yml +++ b/openapi.yml @@ -100,6 +100,18 @@ paths: schema: type: string deprecated: true + - name: date + in: query + schema: + type: string + - name: start + in: query + schema: + type: string + - name: end + in: query + schema: + type: string responses: '200': description: OK