@@ -174,6 +174,91 @@ public function jsonPaginate()
174
174
->appends (request ()->query ());
175
175
}
176
176
177
+ /**
178
+ * Check if entity has relation
179
+ *
180
+ * @param string $relation
181
+ *
182
+ * @return $this
183
+ */
184
+ public function has ($ relation )
185
+ {
186
+ $ this ->model = $ this ->model ->has ($ relation );
187
+
188
+ return $ this ;
189
+ }
190
+
191
+ /**
192
+ * Load relations
193
+ *
194
+ * @param array|string $relations
195
+ *
196
+ * @return $this
197
+ */
198
+ public function with ($ relations )
199
+ {
200
+ $ this ->model = $ this ->model ->with ($ relations );
201
+
202
+ return $ this ;
203
+ }
204
+
205
+ /**
206
+ * Add subselect queries to count the relations.
207
+ *
208
+ * @param mixed $relations
209
+ *
210
+ * @return $this
211
+ */
212
+ public function withCount ($ relations )
213
+ {
214
+ $ this ->model = $ this ->model ->withCount ($ relations );
215
+ return $ this ;
216
+ }
217
+
218
+ /**
219
+ * Load relation with closure
220
+ *
221
+ * @param string $relation
222
+ * @param closure $closure
223
+ *
224
+ * @return $this
225
+ */
226
+ public function whereHas ($ relation , $ closure )
227
+ {
228
+ $ this ->model = $ this ->model ->whereHas ($ relation , $ closure );
229
+
230
+ return $ this ;
231
+ }
232
+
233
+ /**
234
+ * Set hidden fields
235
+ *
236
+ * @param array $fields
237
+ *
238
+ * @return $this
239
+ */
240
+ public function hidden (array $ fields )
241
+ {
242
+ $ this ->model ->setHidden ($ fields );
243
+
244
+ return $ this ;
245
+ }
246
+
247
+ /**
248
+ * Set the "orderBy" value of the query.
249
+ *
250
+ * @param mixed $column
251
+ * @param string $direction
252
+ *
253
+ * @return $this
254
+ */
255
+ public function orderBy ($ column , $ direction = 'asc ' )
256
+ {
257
+ $ this ->model = $ this ->model ->orderBy ($ column , $ direction );
258
+
259
+ return $ this ;
260
+ }
261
+
177
262
/**
178
263
* Query Scope
179
264
*
0 commit comments