README
This commit is contained in:
@@ -10,8 +10,16 @@ namespace Element\Search;
|
||||
|
||||
class Search {
|
||||
|
||||
/* @var $model \Illuminate\Database\Eloquent\Model */
|
||||
/**
|
||||
* Searches the collection of given $model type for
|
||||
* $string and returns the results.
|
||||
*
|
||||
* @param SearchableContract $model
|
||||
* @param $string
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function search( SearchableContract $model, $string ){
|
||||
/* @var $model \Illuminate\Database\Eloquent\Model */
|
||||
$query = $this->formatQuery( $string );
|
||||
$models = $model->all();
|
||||
$returns = [];
|
||||
@@ -114,6 +122,13 @@ class Search {
|
||||
return collect( $returns );
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats the string into an array of non-punctuated,
|
||||
* non-duplicated, lowercase words.
|
||||
*
|
||||
* @param $string
|
||||
* @return array
|
||||
*/
|
||||
public function formatQuery( $string ){
|
||||
$words = explode(' ', $string);
|
||||
$return = [];
|
||||
|
||||
Reference in New Issue
Block a user