Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
7 / 7 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
Searchable | |
100.00% |
7 / 7 |
|
100.00% |
2 / 2 |
3 | |
100.00% |
1 / 1 |
search | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
2 | |||
getSearchWeight | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | namespace Baril\Sqlout; |
4 | |
5 | use Laravel\Scout\Searchable as ScoutSearchable; |
6 | |
7 | trait Searchable |
8 | { |
9 | use ScoutSearchable; |
10 | |
11 | /** |
12 | * Perform a search against the model's indexed data. |
13 | * |
14 | * @param string $query |
15 | * @param \Closure $callback |
16 | * @return \Laravel\Scout\Builder |
17 | */ |
18 | public static function search($query = '', $callback = null) |
19 | { |
20 | return app(Builder::class, [ |
21 | 'model' => new static(), |
22 | 'query' => $query, |
23 | 'callback' => $callback, |
24 | 'softDelete' => static::usesSoftDelete() && config('scout.soft_delete', false), |
25 | ]); |
26 | } |
27 | |
28 | /** |
29 | * Get the weight of the specified field. |
30 | * |
31 | * @param string $field |
32 | * @return int |
33 | */ |
34 | public function getSearchWeight($field) |
35 | { |
36 | return $this->weights[$field] ?? 1; |
37 | } |
38 | } |