Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion src/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class Search {
'find' => '',
'searchGroup' => '',
'from' => null,
'limit' => null,
];

/**
Expand Down Expand Up @@ -47,6 +48,11 @@ class Search {
*/
protected $from = '';

/**
* @var int
*/
protected $limit = null;

/**
* HTTP Client Instance
* @see \GuzzleHttp\Client
Expand Down Expand Up @@ -93,6 +99,7 @@ public function resetComponents() {
'find' => '',
'searchGroup' => '',
'from' => null,
'limit' => null,
];
}

Expand Down Expand Up @@ -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;
}
/**
Expand Down Expand Up @@ -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'])) {
Expand Down Expand Up @@ -342,4 +358,4 @@ public function notFind($value_or_array_or_callable)
{
return $this->find($value_or_array_or_callable, 'andnot');
}
}
}