diff --git a/src/Search.php b/src/Search.php index ef15f69..cdea7d4 100644 --- a/src/Search.php +++ b/src/Search.php @@ -18,6 +18,7 @@ class Search { 'find' => '', 'searchGroup' => '', 'from' => null, + 'limit' => null, ]; /** @@ -47,6 +48,11 @@ class Search { */ protected $from = ''; + /** + * @var int + */ + protected $limit = null; + /** * HTTP Client Instance * @see \GuzzleHttp\Client @@ -93,6 +99,7 @@ public function resetComponents() { 'find' => '', 'searchGroup' => '', 'from' => null, + 'limit' => null, ]; } @@ -189,6 +196,10 @@ public function compiled() { . 'RETURNING ' . $this->components['from'] . '(' . $this->components['select'] . ')'; + if ($this->components['limit']) { + $query .= ' LIMIT ' . $this->components['limit']; + } + return $query; } /** @@ -254,6 +265,11 @@ public function from($from) { return $this; } + public function limit($limit) { + $this->components['limit'] = (int)$limit; + return $this; + } + public function in($searchGroup) { $searchGroup = strtoupper($searchGroup); if (!in_array($searchGroup, ['ALL', 'NAME', 'EMAIL', 'PHONE', 'SIDEBAR'])) { @@ -342,4 +358,4 @@ public function notFind($value_or_array_or_callable) { return $this->find($value_or_array_or_callable, 'andnot'); } -} \ No newline at end of file +}