forked from mirrors/easyappointments
Add date, from and till query parameters to the filter the appointments index results by date (#1134).
This commit is contained in:
parent
e2c3137262
commit
f389608aa1
2 changed files with 43 additions and 2 deletions
|
@ -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)
|
||||
|
|
12
openapi.yml
12
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
|
||||
|
|
Loading…
Reference in a new issue