diff --git a/basics/transforming-dto-data.md b/basics/transforming-dto-data.md index 9f2c6d6..e7802b5 100644 --- a/basics/transforming-dto-data.md +++ b/basics/transforming-dto-data.md @@ -56,6 +56,16 @@ $dto->toModel(\App\Models\User::class); // } ``` +### Custom transforming +If you want to build your own Data Transformer, you can use the `buildDataForExport()` method to retrieve the validated data with your custom mappings. + +```php +public function toObject(): object +{ + return (object) $this->buildDataForExport(); +} +``` + ## Transforming Nested Data Be aware that when transforming the DTO, all the properties are also going to be transformed: