diff --git a/src/Contracts/Http/Api/CrudElasticBehaviorTrait.php b/src/Contracts/Http/Api/CrudElasticBehaviorTrait.php index 44ddf61e..f2a1da50 100644 --- a/src/Contracts/Http/Api/CrudElasticBehaviorTrait.php +++ b/src/Contracts/Http/Api/CrudElasticBehaviorTrait.php @@ -39,7 +39,17 @@ protected function processRequest(RequestInterface $request) : array //parse the request $parse = new QueryParser($this->model, $request->getQuery()); $parse->setAdditionalQueryFields($this->additionalSearchFields); + if ($this->customSort) { + $parse->setSort($this->customSort); + } + + if ($this->customLimit) { + $parse->setLimit($this->customLimit); + } + if ($this->customColumns) { + $parse->setFields($this->customColumns); + } //convert to SQL return [ 'sql' => $parse diff --git a/tests/integration/Contracts/Http/CrudElasticBehaviorTest.php b/tests/integration/Contracts/Http/CrudElasticBehaviorTest.php index ae6228aa..35169440 100644 --- a/tests/integration/Contracts/Http/CrudElasticBehaviorTest.php +++ b/tests/integration/Contracts/Http/CrudElasticBehaviorTest.php @@ -19,6 +19,9 @@ class CrudElasticBehaviorTest extends PhalconUnitTestCase protected ?RequestInterface $request = null; public $model; + protected $customSort = null; + protected $customLimit = null; + protected $customColumns = null; public function testIndex() {