1 | <?php |
||
12 | trait SearchTrait |
||
13 | { |
||
14 | private static $searchFields = [ ]; |
||
15 | |||
16 | 15 | private static function setup() |
|
17 | { |
||
18 | 15 | if (!is_subclass_of(static::class, Model::class)) { |
|
1 ignored issue
–
show
|
|||
19 | 1 | throw new \Exception( |
|
20 | 1 | 'SearchTrait must only be used with Eloquent models, [' . get_called_class() . '] used.' |
|
21 | 1 | ); |
|
22 | } |
||
23 | |||
24 | 15 | static::searchFields(); |
|
25 | 15 | } |
|
26 | |||
27 | 1 | private static function searchFields() |
|
28 | { |
||
29 | 1 | throw new \Exception("Method [searchFields] must exist and be static."); |
|
30 | } |
||
31 | |||
32 | /** |
||
33 | * @param array $fields |
||
34 | */ |
||
35 | 15 | public static function setSearchFields(array $fields) |
|
39 | |||
40 | /** |
||
41 | * @return array |
||
42 | */ |
||
43 | 2 | public static function getSearchFields() |
|
47 | |||
48 | /** |
||
49 | * @return mixed |
||
50 | */ |
||
51 | 2 | public static function search() |
|
60 | |||
61 | 15 | public static function bootSearchTrait() |
|
62 | { |
||
68 | |||
69 | /** |
||
70 | * @param Store $store |
||
71 | * @return \Closure |
||
72 | */ |
||
73 | 15 | private static function insertCallback(Store $store) |
|
80 | |||
81 | /** |
||
82 | * @param Store $store |
||
83 | * @return \Closure |
||
84 | */ |
||
85 | private static function deleteCallback(Store $store) |
||
92 | } |
||
93 |