Skip to content

Commit

Permalink
Added explanation on how to customise your own DataTransformer (#6)
Browse files Browse the repository at this point in the history
* Added explanation on how to customise your own DataTransformer

* Updated the description and added an example
  • Loading branch information
felixbessler authored Jul 19, 2024
1 parent e782d5b commit 6d064db
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions basics/transforming-dto-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 6d064db

Please sign in to comment.