group container packing lists by customer

This commit is contained in:
omair saleh
2022-03-05 16:34:41 +08:00
parent a54aefcf9f
commit 9e95da84c4
+3 -1
View File
@@ -30,7 +30,9 @@ class ContainerResource extends JsonResource
'remarks' => RemarkResource::collection($this->remarks),
'status' => $this->status,
'packing_lists' => $this->whenLoaded('packingLists', PackingListResource::collection($this->whenLoaded('packingLists', function(){
return $this->packingLists()->whereHas('packages')->get();
return $this->packingLists()->whereHas('packages')->get()->groupBy(function ($package) {
return $package->packingList->owner->company_module_id;
});
})))
];
}