Laravel sum, min, max, avg columns in related model, sorting by relations and limit relations rows
Hi, @hairullana try to add trait in order model and use something like this
$pl_orders = PackingListOrder::where('packing_list_id', $p1->id)
->with(['order' => function ($query) {
$query->with(['customer', 'country', 'items'])
->withSum('items:picked,missing');
}])->get();