mirror of
https://github.com/alextselegidis/easyappointments.git
synced 2024-11-24 00:43:28 +03:00
Add unavailabilities API capabilities to query by date, from, till & providerId
This commit is contained in:
parent
dc68f3bcaf
commit
0a3089bb4b
1 changed files with 35 additions and 1 deletions
|
@ -50,8 +50,42 @@ class Unavailabilities_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');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Provider ID query param.
|
||||||
|
|
||||||
|
$provider_id = request('providerId');
|
||||||
|
|
||||||
|
if (!empty($provider_id)) {
|
||||||
|
$where['id_users_provider'] = $provider_id;
|
||||||
|
}
|
||||||
|
|
||||||
$unavailabilities = empty($keyword)
|
$unavailabilities = empty($keyword)
|
||||||
? $this->unavailabilities_model->get(null, $limit, $offset, $order_by)
|
? $this->unavailabilities_model->get($where, $limit, $offset, $order_by)
|
||||||
: $this->unavailabilities_model->search($keyword, $limit, $offset, $order_by);
|
: $this->unavailabilities_model->search($keyword, $limit, $offset, $order_by);
|
||||||
|
|
||||||
foreach ($unavailabilities as &$unavailability) {
|
foreach ($unavailabilities as &$unavailability) {
|
||||||
|
|
Loading…
Reference in a new issue