@@ -437,20 +437,25 @@ private function parseFields($fields)
437
437
438
438
$ parent = implode (". " , $ fieldParts );
439
439
440
- // The parent might already been set because we cannot rely on order
441
- // in which user sends relations in request
442
- if (!isset ($ this ->relations [$ parent ])) {
443
- $ this ->relations [$ parent ] = [
444
- "limit " => config ("api.defaultLimit " ),
445
- "offset " => 0 ,
446
- "order " => "chronological " ,
447
- "fields " => isset ($ singular ) ? [$ singular ] : [] ,
448
- "userSpecifiedFields " => true
449
- ];
440
+ if ($ relation instanceof HasOne || $ relation instanceof HasMany) {
441
+ $ this ->relations [$ fieldName ]["fields " ][] = $ singular ;
450
442
}
451
443
else {
452
- if (isset ($ singular )) {
453
- $ this ->relations [$ parent ]["fields " ][] = $ singular ;
444
+ // The parent might already been set because we cannot rely on order
445
+ // in which user sends relations in request
446
+ if (!isset ($ this ->relations [$ parent ])) {
447
+ $ this ->relations [$ parent ] = [
448
+ "limit " => config ("api.defaultLimit " ),
449
+ "offset " => 0 ,
450
+ "order " => "chronological " ,
451
+ "fields " => isset ($ singular ) ? [$ singular ] : [],
452
+ "userSpecifiedFields " => true
453
+ ];
454
+ }
455
+ else {
456
+ if (isset ($ singular )) {
457
+ $ this ->relations [$ parent ]["fields " ][] = $ singular ;
458
+ }
454
459
}
455
460
}
456
461
0 commit comments