We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b611dea commit 65a406aCopy full SHA for 65a406a
README.md
@@ -1041,6 +1041,21 @@ class UserController extends Controller
1041
}
1042
```
1043
1044
+You can also return a collection/list of your DTOs as a response using the `ResourceDTO::collection()` method:
1045
+
1046
+```php
1047
+class UserController extends Controller
1048
+{
1049
+ public function index()
1050
+ {
1051
+ return UserResourceDTO::collection(User::all());
1052
+ }
1053
+}
1054
+```
1055
1056
+This way every item in the collection will be converted to a `UserResourceDTO` instance before sending
1057
+the response to the client, using all the typing, casting and mapping features of your DTO class.
1058
1059
To generate a `ResourceDTO` you can use the `--resource` flag:
1060
1061
```bash
0 commit comments