diff --git a/app/Console/Commands/SendProductionReport.php b/app/Console/Commands/SendProductionReport.php index 89edc85a..c74fbf8a 100644 --- a/app/Console/Commands/SendProductionReport.php +++ b/app/Console/Commands/SendProductionReport.php @@ -258,13 +258,17 @@ class SendProductionReport extends Command $productionQuantity = \App\Models\QualityValidation::where('plant_id', $plant->id) ->where('line_id', $line->id) - ->whereIn('item_id', $itemIds) + ->whereHas('stickerMaster', function ($query) use ($itemIds) { + $query->whereIn('item_id', $itemIds); + }) ->whereBetween('created_at', [$startDate, $endDate]) ->count(); $nonPlannedproductionQuantity = \App\Models\QualityValidation::where('plant_id', $plant->id) ->where('line_id', $line->id) - ->whereNotIn('item_id', $itemIds) + ->whereHas('stickerMaster', function ($query) use ($itemIds) { + $query->whereIn('item_id', $itemIds); + }) ->whereBetween('created_at', [$startDate, $endDate]) ->count(); @@ -297,7 +301,9 @@ class SendProductionReport extends Command $dayproductionQuantity = \App\Models\QualityValidation::where('plant_id', $plant->id) ->where('line_id', $line->id) - ->whereIn('item_id', $itemIds) + ->whereHas('stickerMaster', function ($query) use ($itemIds) { + $query->whereIn('item_id', $itemIds); + }) ->whereBetween('created_at', [ $startDate->copy()->setTime(8, 0, 0), $startDate->copy()->setTime(19, 30, 0), @@ -306,7 +312,9 @@ class SendProductionReport extends Command $nightproductionQuantity = \App\Models\QualityValidation::where('plant_id', $plant->id) ->where('line_id', $line->id) - ->whereIn('item_id', $itemIds) + ->whereHas('stickerMaster', function ($query) use ($itemIds) { + $query->whereIn('item_id', $itemIds); + }) ->whereBetween('created_at', [ $startDate->copy()->setTime(19, 30, 0), $endDate->copy()->setTime(8, 0, 0),