timezone(env('APP_TIMEZONE')) ->toDateTimeString(); } public static function boot() { parent::boot(); static::created(function($data) { $activity = Activity::find($data->activity_id); $assignedMaterial = AssignMaterial::find($data->assign_material_id); $activity->biaya_actual += floatval($assignedMaterial->budget) * floatval($data->qty); $activity->save(); }); static::deleted(function($data) { $activity = Activity::find($data->activity_id); $assignedMaterial = AssignMaterial::find($data->assign_material_id); $activity->biaya_actual -= floatval($assignedMaterial->budget) * floatval($data->qty); $activity->save(); }); } }