Transforming DTO Data
You can convert your DTO to some formats:
To array
To JSON string
To Eloquent Model
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.
Transforming Nested Data
Be aware that when transforming the DTO, all the properties are also going to be transformed:
Scalar Data Type
and Array
properties will preserve their values.
stdClass
properties will be transformed into arrays using type casting.
UnitEnum
properties are going to be transformed into the case name.
BackedEnum
properties are going to be transformed into the case value.
Carbon
and CarbonImmutable
properties are going to be transformed into strings using the ->toISOString()
method.
Collection
, Model
and DTO
properties will have their nested data transformed using the same logic as above.
Last updated