diff --git a/app/Models/Activity.php b/app/Models/Activity.php index ff6d559..3bb06fb 100644 --- a/app/Models/Activity.php +++ b/app/Models/Activity.php @@ -18,6 +18,7 @@ class Activity extends Model const CREATED_AT = 'created_at'; const UPDATED_AT = 'updated_at'; + // persentase bobot gak kepake yg dipakenya bobot_planning protected $fillable = [ 'proyek_id', 'parent_id', 'kode_sortname', 'name', 'rencana_biaya', 'start_date', 'end_date', 'area_kerja', 'biaya_actual', 'persentase_bobot', 'persentase_progress', @@ -58,7 +59,7 @@ class Activity extends Model static::updated(function($data) { $data->updateBobot(); $data->updateCostPlanning(); - if($data->persentase_bobot){ + if($data->bobot_planning){ $data->updatePersentaseProgress(); $data->updateCostActual(); } @@ -70,7 +71,7 @@ class Activity extends Model $data->updateBobot(true); $data->updateCostPlanning(); - if($data->persentase_bobot){ + if($data->bobot_planning){ $data->updatePersentaseProgress(); $data->updateCostActual(); } @@ -119,6 +120,7 @@ class Activity extends Model private function updatePersentaseProgress() { + print_r(2); if($parent = Activity::find($this->parent_id)){ $parentActWeight = $parent->bobot_planning; @@ -129,9 +131,11 @@ class Activity extends Model $currentActProportionalProgress = ($currentActWeight / $parentActWeight) * $child->persentase_progress; $totalChildProportionalProgress += $currentActProportionalProgress; } - $parent->update([ + print_r($totalChildProportionalProgress); + $x = $parent->update([ "persentase_progress" => $totalChildProportionalProgress ]); + print_r($x); } }