diff --git a/app/Models/UserToActivity.php b/app/Models/UserToActivity.php index a33667c..76f948a 100644 --- a/app/Models/UserToActivity.php +++ b/app/Models/UserToActivity.php @@ -1,61 +1,61 @@ -activity_id); - $getWorkingHours = UserToProyek::where('user_id', $data->user_id)->where('proyek_id', $activity->proyek_id)->first(); - - $salary = ($getWorkingHours->standart_rate * $activity->duration) * ($getWorkingHours->max_used / 100); - - if($getWorkingHours->uom_standart_rate == "Hour") - $salary = ($getWorkingHours->standart_rate * 8) * $activity->duration * ($getWorkingHours->max_used / 100); - - $activity->rencana_biaya += $salary; - $activity->save(); - }); - - static::deleted(function($data) { - $activity = Activity::find($data->activity_id); - - $getWorkingHours = UserToProyek::where('user_id', $data->user_id)->where('proyek_id', $activity->proyek_id)->first(); - $salary = ($getWorkingHours->standart_rate * $activity->duration) * ($getWorkingHours->max_used / 100); - if($getWorkingHours->uom_standart_rate == "Hour"){ - $salary = ($getWorkingHours->standart_rate * 8) * $activity->duration * ($getWorkingHours->max_used / 100); - } - - $activity->rencana_biaya -= $salary; - if ($activity->rencana_biaya < 0) { - $activity->rencana_biaya = 0; - } - $activity->save(); - }); - - } - -} +activity_id); + $getWorkingHours = UserToProyek::where('user_id', $data->user_id)->where('proyek_id', $activity->proyek_id)->first(); + + $salary = ($getWorkingHours->standart_rate * $activity->duration) * ($getWorkingHours->max_used / 100); + + if($getWorkingHours->uom_standart_rate == "Hour") + $salary = ($getWorkingHours->standart_rate * 8) * $activity->duration * ($getWorkingHours->max_used / 100); + + $activity->rencana_biaya += $salary; + $activity->save(); + }); + + static::deleted(function($data) { + $activity = Activity::find($data->activity_id); + + $getWorkingHours = UserToProyek::where('user_id', $data->user_id)->where('proyek_id', $activity->proyek_id)->first(); + $salary = ($getWorkingHours->standart_rate * $activity->duration) * ($getWorkingHours->max_used / 100); + if($getWorkingHours->uom_standart_rate == "Hour"){ + $salary = ($getWorkingHours->standart_rate * 8) * $activity->duration * ($getWorkingHours->max_used / 100); + } + + $activity->rencana_biaya -= $salary; + if ($activity->rencana_biaya < 0) { + $activity->rencana_biaya = 0; + } + $activity->save(); + }); + + } + +}