Browse Source

fix: total_progress update logic

dev-wahyun
wahyun 3 months ago
parent
commit
033373ebf0
  1. 17
      app/Http/Controllers/ProjectController.php

17
app/Http/Controllers/ProjectController.php

@ -291,6 +291,23 @@ class ProjectController extends Controller
$builder = $dataBuilder['builder'];
$countBuilder = $dataBuilder['count'];
$dataGet = $builder->get();
foreach($dataGet as $p) {
$project = Project::find($p->id);
if (!$project) continue;
$act = Activity::select('persentase_progress as total_progress')
->where([
['proyek_id', $p->id],
['parent_id', null]
])
->first();
if ($act) {
$project->persentase_progress = $act->total_progress;
} else {
$project->persentase_progress = 0;
}
$project->save();
}
$totalRecord = $countBuilder->count();
return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet, 'totalRecord' => $totalRecord], 200);
}

Loading…
Cancel
Save