Skip to content

Commit c88ecb7

Browse files
PR cleanup
1 parent bd7b609 commit c88ecb7

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

docs/advanced-usage/available-mappers.md renamed to docs/advanced-usage/available-property-mappers.md

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
---
2-
title: Available mappers
2+
title: Available property mappers
33
weight: 19
44
---
55

6-
Sometimes the property names in the array from which you're creating a data object might be different.
7-
You can use mappers for property names when it is created from an array using attributes:
6+
In previous sections we've already seen how
7+
to [create](/docs/laravel-data/v4/as-a-data-transfer-object/mapping-property-names) data objects where the keys of the
8+
payload differ from the property names of the data object. It is also possible
9+
to [transform](/docs/laravel-data/v4/as-a-resource/mapping-property-names) data objects to an
10+
array/json/... where the keys of the payload differ from the property names of the data object.
11+
12+
These mappings can be set manually put the package also provide a set of mappers that can be used to automatically map
13+
property names:
814

915
```php
1016
class ContractData extends Data
@@ -39,3 +45,16 @@ ContractData::from([
3945
'ADDRESSLINE2' => 'some address line 2',
4046
]);
4147
```
48+
49+
When transforming such a data object the payload will look like this:
50+
51+
```json
52+
{
53+
"name" : "Rick Astley",
54+
"record_company" : "RCA Records",
55+
"country field" : "Belgium",
56+
"CityName" : "Antwerp",
57+
"addressline1" : "some address line 1",
58+
"ADDRESSLINE2" : "some address line 2"
59+
}
60+
```

docs/as-a-data-transfer-object/mapping-property-names.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,4 @@ SongData::from([
9191
]);
9292
```
9393

94-
You can also use other mappers to input and output property name mapping (see [available mappers](/docs/laravel-data/v4/advanced-usage/available-mappers)).
94+
The package has a set of default mappers available, you can find them [here](/docs/laravel-data/v4/advanced-usage/available-property-mappers).

docs/as-a-resource/mapping-property-names.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,4 @@ And a transformed version of the data object will look like this:
8181
]
8282
```
8383

84-
You can also use other mappers to input and output property name mapping (see [available mappers](/docs/laravel-data/v4/advanced-usage/available-mappers)).
84+
The package has a set of default mappers available, you can find them [here](/docs/laravel-data/v4/advanced-usage/available-property-mappers).

0 commit comments

Comments
 (0)