我正在尝试更新我的功能,该功能正在搜索由开始日期 - 结束日期过滤的数据。
如果用户没有插入任何日期,我希望该功能获得所有相关搜索。我怎样才能做到这一点?
这是我的功能:
$conditions = $this->CustodyKeys->find()
->where(function ($exp, $q) {
return $exp->between('CustodyKeys.received_date',
$this>request->query['received_date_from'],
$this->request->query['received_date_to']);
})
->where(function ($exp, $q) {
return $exp->between('CustodyKeys.return_date',
$this->request->query['return_date_from'],
$this->request->query['return_date_to']);
})
->contain('HoldersKeys')
->contain('KeysManagement.DoorsManagement')
->contain('KeysCustodyType')
->contain('KeysCustodyStatus')
->where(['KeysCustodyType.id' =>1])
->where(['KeysCustodyStatus.id'=>
$this->request->query['keys_custody_status_name']])