This repository was archived by the owner on Nov 4, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +31
-0
lines changed Expand file tree Collapse file tree 3 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -221,6 +221,14 @@ App\MyModel::search('phone')
221
221
->get();
222
222
```
223
223
224
+ If you need to load relations you can use the ` with ` method:
225
+
226
+ ``` php
227
+ App\MyModel::search('phone')
228
+ ->with('makers')
229
+ ->get();
230
+ ```
231
+
224
232
In addition to standard functionality the package offers you the possibility to filter data in Elasticsearch without specifying a query string:
225
233
226
234
``` php
Original file line number Diff line number Diff line change @@ -11,6 +11,8 @@ class FilterBuilder extends Builder
11
11
'must_not ' => []
12
12
];
13
13
14
+ public $ with ;
15
+
14
16
public function __construct ($ model , $ callback = null )
15
17
{
16
18
$ this ->model = $ model ;
@@ -133,4 +135,11 @@ public function buildPayload()
133
135
{
134
136
return $ this ->engine ()->buildSearchQueryPayloadCollection ($ this );
135
137
}
138
+
139
+ public function with ($ relations )
140
+ {
141
+ $ this ->with = $ relations ;
142
+
143
+ return $ this ;
144
+ }
136
145
}
Original file line number Diff line number Diff line change @@ -224,4 +224,18 @@ public function getTotalCount($results)
224
224
{
225
225
return $ results ['hits ' ]['total ' ];
226
226
}
227
+
228
+ /**
229
+ * @inheritdoc
230
+ */
231
+ public function get (Builder $ builder )
232
+ {
233
+ $ collection = parent ::get ($ builder );
234
+
235
+ if (isset ($ builder ->with ) && $ collection ->count () > 0 ) {
236
+ $ collection ->load ($ builder ->with );
237
+ }
238
+
239
+ return $ collection ;
240
+ }
227
241
}
You can’t perform that action at this time.
0 commit comments