From 7845394dcf5be32ddc45af78e075eb24774b8e08 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Wed, 30 Sep 2026 14:16:39 +0530 Subject: [PATCH] Changed logic in production target plan --- app/Livewire/ProductionTargetPlan.php | 14 +++++--------- .../livewire/production-target-plan.blade.php | 2 +- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/app/Livewire/ProductionTargetPlan.php b/app/Livewire/ProductionTargetPlan.php index 93d16c35..9feb4a99 100644 --- a/app/Livewire/ProductionTargetPlan.php +++ b/app/Livewire/ProductionTargetPlan.php @@ -20,7 +20,7 @@ class ProductionTargetPlan extends Component public $dates = []; - public $monthlyRecords; + public $monthlyRecords = []; public $leaveDates = []; @@ -629,16 +629,11 @@ class ProductionTargetPlan extends Component } public function loadMonthlyPlan($year, $month, $plantId, $lineId){ - $this->monthlyRecords = ProductionPlan::query() - ->selectRaw(' - plant_id, - line_id, - SUM(plan_quantity) as monthly_plan - ') + return ProductionPlan::where('plant_id', $plantId) + ->where('line_id', $lineId) ->whereYear('created_at', $year) ->whereMonth('created_at', $month) - ->groupBy('plant_id', 'line_id') - ->get(); + ->sum('plan_quantity'); } @@ -655,6 +650,7 @@ class ProductionTargetPlan extends Component // return view('livewire.production-target-plan'); return view('livewire.production-target-plan', [ 'records' => $this->records, + 'monthlyRecords' => $this->monthlyRecords, 'dates' => $this->dates, ]); } diff --git a/resources/views/livewire/production-target-plan.blade.php b/resources/views/livewire/production-target-plan.blade.php index f3614cb9..0d928d84 100644 --- a/resources/views/livewire/production-target-plan.blade.php +++ b/resources/views/livewire/production-target-plan.blade.php @@ -19,7 +19,7 @@ - @forelse ($records as $index => $record) + @forelse ($monthlyRecords as $index => $record)