PHP Class Mmanos\Search\Query

Show file Open project: mmanos/laravel-search Class Usage Examples

Protected Properties

Property Type Description
$callbacks array Any user defined callback functions to help manipulate the raw query instance.
$callbacks_executed boolean Prevents multiple executions.
$columns array The columns that should be returned.
$conditions array The search conditions for the query.
$index Mmanos\Search\Index The search index instance.
$limit integer The maximum number of records to return.
$offset integer The number of records to skip.
$query mixed The raw query used by the current search index driver.

Public Methods

Method Description
__construct ( Mmanos\Search\Index $index ) : void Create a new search query builder instance.
addCallback ( Closure $callback, array | string $driver = null ) : Query Add a custom callback fn to be called just before the query is executed.
count ( ) : integer Execute the current query and return the total number of results.
delete ( ) : void Execute the current query and perform delete operations on each document found.
get ( ) : array Execute the current query and return the results.
limit ( integer $limit, integer $offset ) : Query Set the "limit" and "offset" value of the query.
paginate ( integer $num = 15 ) : Illuminate\Pagination\LengthAwarePaginator Execute the current query and return a paginator for the results.
search ( string $field, mixed $value, array $options = [] ) : Query Add a basic search clause to the query.
select ( array $columns = ['*'] ) : Query Set the columns to be selected.
where ( string $field, mixed $value ) : Query Add a basic where clause to the query. A where clause filter attemtps to match the value you specify as an entire "phrase". It does not guarantee an exact match of the entire field value.
whereLocation ( float $lat, float $long, integer $distance_in_meters = 10000 ) : Query Add a geo distance where clause to the query.

Protected Methods

Method Description
executeCallbacks ( ) : void Execute any callback functions. Only execute once.

Method Details

__construct() public method

Create a new search query builder instance.
public __construct ( Mmanos\Search\Index $index ) : void
$index Mmanos\Search\Index
return void

addCallback() public method

Add a custom callback fn to be called just before the query is executed.
public addCallback ( Closure $callback, array | string $driver = null ) : Query
$callback Closure
$driver array | string
return Query

count() public method

Execute the current query and return the total number of results.
public count ( ) : integer
return integer

delete() public method

Execute the current query and perform delete operations on each document found.
public delete ( ) : void
return void

executeCallbacks() protected method

Execute any callback functions. Only execute once.
protected executeCallbacks ( ) : void
return void

get() public method

Execute the current query and return the results.
public get ( ) : array
return array

limit() public method

Set the "limit" and "offset" value of the query.
public limit ( integer $limit, integer $offset ) : Query
$limit integer
$offset integer
return Query

paginate() public method

Execute the current query and return a paginator for the results.
public paginate ( integer $num = 15 ) : Illuminate\Pagination\LengthAwarePaginator
$num integer
return Illuminate\Pagination\LengthAwarePaginator

select() public method

Set the columns to be selected.
public select ( array $columns = ['*'] ) : Query
$columns array
return Query

where() public method

Add a basic where clause to the query. A where clause filter attemtps to match the value you specify as an entire "phrase". It does not guarantee an exact match of the entire field value.
public where ( string $field, mixed $value ) : Query
$field string
$value mixed
return Query

whereLocation() public method

Add a geo distance where clause to the query.
public whereLocation ( float $lat, float $long, integer $distance_in_meters = 10000 ) : Query
$lat float
$long float
$distance_in_meters integer
return Query

Property Details

$callbacks protected property

Any user defined callback functions to help manipulate the raw query instance.
protected array $callbacks
return array

$callbacks_executed protected property

Prevents multiple executions.
protected bool $callbacks_executed
return boolean

$columns protected property

The columns that should be returned.
protected array $columns
return array

$conditions protected property

The search conditions for the query.
protected array $conditions
return array

$index protected property

The search index instance.
protected Index,Mmanos\Search $index
return Mmanos\Search\Index

$limit protected property

The maximum number of records to return.
protected int $limit
return integer

$offset protected property

The number of records to skip.
protected int $offset
return integer

$query protected property

The raw query used by the current search index driver.
protected mixed $query
return mixed