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();
|
$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)
|
$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);
|
: $this->appointments_model->search($keyword, $limit, $offset, $order_by);
|
||||||
|
|
||||||
foreach ($appointments as &$appointment)
|
foreach ($appointments as &$appointment)
|
||||||
|
@ -97,7 +126,7 @@ class Appointments_api_v1 extends EA_Controller {
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$fields = $this->api->request_fields();
|
$fields = $this->api->request_fields();
|
||||||
|
|
||||||
$with = $this->api->request_with();
|
$with = $this->api->request_with();
|
||||||
|
|
||||||
$appointment = $this->appointments_model->find($id);
|
$appointment = $this->appointments_model->find($id);
|
||||||
|
|
12
openapi.yml
12
openapi.yml
|
@ -100,6 +100,18 @@ paths:
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
deprecated: true
|
deprecated: true
|
||||||
|
- name: date
|
||||||
|
in: query
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
- name: start
|
||||||
|
in: query
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
- name: end
|
||||||
|
in: query
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: OK
|
description: OK
|
||||||
|
|
Loading…
Reference in a new issue