public static function OtherCharges($id, $account_id, $amount, $bill_no, $for_month, $planchange_id, $topup_id) { $othercharges = OtherCharges::where('id', $id)->first(); if (count($othercharges) != 0) { $othercharges->account_id = $account_id; $othercharges->amount = $amount; $othercharges->for_month = $for_month; $othercharges->date = date("Y-m-d"); $othercharges->save(); return $othercharges; } else { $OtherCharges = new OtherCharges(); $OtherCharges->account_id = $account_id; $OtherCharges->amount = $amount; $OtherCharges->for_month = $for_month; $OtherCharges->date = date("Y-m-d"); $OtherCharges->is_considered = 1; $OtherCharges->save(); $bill_info_new = new Billinformation(); $bill_info_new->bill_no = $bill_no; $bill_info_new->other_charges_id = $OtherCharges->id; $bill_info_new->save(); if ($planchange_id) { $plaChange = PlanChangeDetail::where('id', $planchange_id)->first(); $plaChange->other_charges_id = $OtherCharges->id; $plaChange->save(); } else { $topup = TopupDetail::where('id', $topup_id)->first(); $topup->other_charges_id = $OtherCharges->id; $topup->save(); } return $OtherCharges; } }