File tree 1 file changed +27
-0
lines changed
1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -205,6 +205,33 @@ The field defintions are pretty flexible. Better learn by examples by yourself
205
205
]
206
206
```
207
207
208
+ ## One row for each relation
209
+
210
+ If you have a relation you want to put into one row and preserve it's parent as one row if it hasn't a relation, you can
211
+ use the following:
212
+
213
+ ``` php
214
+ public function handle()
215
+ {
216
+ // ...
217
+
218
+ // relation has to be loaded in items of course
219
+ $items->each(function (Item $item) use ($export) {
220
+ $export->addRowForEachRelation($item, ['relation', 'more.*.relations'], 'fieldAccessorAlias');
221
+ });
222
+
223
+ // ...
224
+ }
225
+
226
+ public function fields(): array
227
+ {
228
+ return [
229
+ 'fieldAccessorAlias.fieldName' => 'Output of relation fieldName if it is existing',
230
+ 'fieldAccessorAlias.fieldNameMoreRelations' => 'Output of more.*.relations fieldName if it is existing',
231
+ ];
232
+ }
233
+ ```
234
+
208
235
## SYLK file format error
209
236
210
237
By default, an exception getting thrown if the first column in the header row is named ` ID ` .
You can’t perform that action at this time.
0 commit comments