1 | <?php |
||
11 | class TNTSearchEngine extends Engine |
||
12 | { |
||
13 | const NO_RESULTS_COUNT = 0; |
||
14 | |||
15 | /** |
||
16 | * @var TNTSearch |
||
17 | */ |
||
18 | protected $tnt; |
||
19 | |||
20 | /** |
||
21 | * @var Builder |
||
22 | */ |
||
23 | protected $builder; |
||
24 | |||
25 | protected $modelCollection; |
||
26 | |||
27 | /** |
||
28 | * Create a new engine instance. |
||
29 | * |
||
30 | * @param TNTSearch $tnt |
||
31 | */ |
||
32 | public function __construct(TNTSearch $tnt) |
||
36 | |||
37 | /** |
||
38 | * Update the given model in the index. |
||
39 | * |
||
40 | * @param Collection $models |
||
41 | * |
||
42 | * @return void |
||
43 | */ |
||
44 | public function update($models) |
||
67 | |||
68 | /** |
||
69 | * Remove the given model from the index. |
||
70 | * |
||
71 | * @param Collection $models |
||
72 | * |
||
73 | * @return void |
||
74 | */ |
||
75 | public function delete($models) |
||
85 | |||
86 | /** |
||
87 | * Perform the given search on the engine. |
||
88 | * |
||
89 | * @param Builder $builder |
||
90 | * |
||
91 | * @return mixed |
||
92 | */ |
||
93 | public function search(Builder $builder) |
||
101 | |||
102 | /** |
||
103 | * Perform the given search on the engine. |
||
104 | * |
||
105 | * @param Builder $builder |
||
106 | * @param int $perPage |
||
107 | * @param int $page |
||
108 | * |
||
109 | * @return mixed |
||
110 | */ |
||
111 | public function paginate(Builder $builder, $perPage, $page) |
||
131 | |||
132 | /** |
||
133 | * Perform the given search on the engine. |
||
134 | * |
||
135 | * @param Builder $builder |
||
136 | * |
||
137 | * @return mixed |
||
138 | */ |
||
139 | protected function performSearch(Builder $builder, array $options = []) |
||
162 | |||
163 | /** |
||
164 | * Get the filter array for the query. |
||
165 | * |
||
166 | * @param Builder $builder |
||
167 | * |
||
168 | * @return array |
||
169 | */ |
||
170 | protected function filters(Builder $builder) |
||
176 | |||
177 | /** |
||
178 | * Map the given results to instances of the given model. |
||
179 | * |
||
180 | * @param mixed $results |
||
181 | * @param \Illuminate\Database\Eloquent\Model $model |
||
182 | * |
||
183 | * @return Collection |
||
184 | */ |
||
185 | public function map($results, $model) |
||
193 | |||
194 | /** |
||
195 | * Pluck and return the primary keys of the given results. |
||
196 | * |
||
197 | * @param mixed $results |
||
198 | * @return \Illuminate\Support\Collection |
||
199 | */ |
||
200 | public function mapIds($results) |
||
204 | |||
205 | /** |
||
206 | * Get the total count from a raw result returned by the engine. |
||
207 | * |
||
208 | * @param mixed $results |
||
209 | * |
||
210 | * @return int |
||
211 | */ |
||
212 | public function getTotalCount($results) |
||
220 | |||
221 | public function initIndex($model) |
||
231 | |||
232 | protected function modelCollection($results) |
||
254 | } |
||
255 |