PHP Trait Devise\Search\SearchableModelTrait

where numbers 1 and 2 are the respective relevance of those columns
Afficher le fichier Open project: devisephp/cms

Protected Properties

Свойство Type Description
$totalWords integer

Méthodes publiques

Méthode Description
scopeSearch ( $query, $search ) : mixed Makes the search process work for a model

Méthodes protégées

Méthode Description
addSelectsToQuery ( &$query, $selects ) Puts all the select clauses to the main query
createSearchQuery ( Query $query, text $search ) : Query Makes the search query to search for text by relevance inside the database using IF statements
filterCommonWords ( array $words ) : array Filter out words like a, the, but, and, her, his, etc <-- even that one
filterQueryWithRelevance ( &$query, $relevance_count ) Adds where clauses to this query based on the relevance
getColumns ( ) : array Returns the search columns
getJoins ( ) : array Returns the tables that has to join
getSearchQueriesForColumn ( string $column, integer $relevance, array $words ) : array Overrides how the relevance is calculated
makeJoins ( &$query ) Adds the join sql to the query

Method Details

addSelectsToQuery() protected méthode

Puts all the select clauses to the main query
protected addSelectsToQuery ( &$query, $selects )
$query
$selects

createSearchQuery() protected méthode

Makes the search query to search for text by relevance inside the database using IF statements
protected createSearchQuery ( Query $query, text $search ) : Query
$query Query
$search text
Résultat Query

filterCommonWords() protected méthode

Filter out words like a, the, but, and, her, his, etc <-- even that one
protected filterCommonWords ( array $words ) : array
$words array
Résultat array

filterQueryWithRelevance() protected méthode

Adds where clauses to this query based on the relevance
protected filterQueryWithRelevance ( &$query, $relevance_count )

getColumns() protected méthode

Returns the search columns
protected getColumns ( ) : array
Résultat array

getJoins() protected méthode

Returns the tables that has to join
protected getJoins ( ) : array
Résultat array

getSearchQueriesForColumn() protected méthode

Overrides how the relevance is calculated
protected getSearchQueriesForColumn ( string $column, integer $relevance, array $words ) : array
$column string
$relevance integer
$words array
Résultat array

makeJoins() protected méthode

Adds the join sql to the query
protected makeJoins ( &$query )
$query

scopeSearch() public méthode

Makes the search process work for a model
public scopeSearch ( $query, $search ) : mixed
$query
$search
Résultat mixed

Property Details

$totalWords protected_oe property

protected int $totalWords
Résultat integer