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)