diff --git a/src/Adapters/QueryBuilder.php b/src/Adapters/QueryBuilder.php index 6151b8b..fd394db 100644 --- a/src/Adapters/QueryBuilder.php +++ b/src/Adapters/QueryBuilder.php @@ -27,7 +27,9 @@ public function getResponse() { }); $this->bind('order', function($order) { - $this->builder->orderBy(implode(', ', $order)); + if (!empty($order)) { + $this->builder->orderBy(implode(', ', $order)); + } }); $builder = new PQueryBuilder([ @@ -37,11 +39,11 @@ public function getResponse() { ]); $filtered = $builder->getPaginate(); - + return $this->formResponse([ 'total' => $total->total_items, 'filtered' => $filtered->total_items, 'data' => $filtered->items->toArray(), ]); } -} \ No newline at end of file +}