Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added explanation on how to customise your own DataTransformer #6

Merged
merged 4 commits into from
Jul 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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