You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/docs/4.0/filtering/filtering.md
+39Lines changed: 39 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -260,6 +260,45 @@ This means that we could use `posts` query for eager loading posts:
260
260
GET: /api/restify/users?related=posts
261
261
```
262
262
263
+
## Custom data
264
+
265
+
You are not limited to add only relations under the `related` array. You can use whatever you want, for instance you can return a simple model, or a collection. Basically any serializable data could be added there. For example:
266
+
267
+
268
+
```php
269
+
public static $related = [
270
+
'foo'
271
+
];
272
+
```
273
+
274
+
Then in the `Post` model we can define this method as:
275
+
276
+
```php
277
+
public function foo() {
278
+
return collect([1, 2]);
279
+
}
280
+
```
281
+
282
+
### Custom data format
283
+
284
+
You can use a custom related cast class (aka transformer). You can do so by modifying the `restify.casts.related` property. The default related cast is `Binaryk\LaravelRestify\Repositories\Casts\RelatedCast`.
285
+
286
+
The cast class should extends the `Binaryk\LaravelRestify\Repositories\Casts\RepositoryCast` abstract class.
0 commit comments