/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $th01 = new th01(); $dethuts = $th01->getDetailHutang($id); foreach ($dethuts as $dethut) { $th02 = th02::find($dethut->idph); $th02->delete(); } $th01 = th01::find($id); $th01->delete(); Session::flash('th01_success', 'Data Telah DiHapus!'); return Redirect::to('inputdata/hutang'); }
function updateHutangTabunganLunas($idph, $idtb) { if ($idph != -1) { $idhut = th02::find($idph)->idhut; $sql = "SELECT COUNT(idtg) as c_idtg\n FROM th02 \n WHERE idhut = {$idhut} AND idtg = 0;"; $count = DB::select(DB::raw($sql)); $flaglunas = $count[0]->c_idtg; if ($flaglunas == 0) { $th01 = th01::find($idhut); $th01->flglns = "Y"; $th01->save(); } } }