json(Marhun::all()); } public function showOneMarhun($norujukan) { $cawangan_all = Cawangan::on('mysql7')->get(); $marhun_all = []; foreach($cawangan_all as $index=>$cawangan){ $marhun = Marhun::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->get(); if(sizeof($marhun) != 0){ array_push($marhun_all,$marhun); } } return response()->json($marhun_all); } public function getAllJemas($kodcaw){ $cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first(); $jemas = Jemas::on($cawangan['mysql'])->get(); return response()->json($jemas); } public function create($kodcaw,Request $request) { $current = Carbon::now(); $current = new Carbon(); $nota = ""; if($request->rosak != ""){ $nota = $nota . $request->rosak; } if($request->putus != ""){ $nota = $nota . ', ' . $request->putus; } if($request->patah != ""){ $nota = $nota . ', ' . $request->patah; } if($request->permata != ""){ $nota = $nota . ', ' . $request->permata; } if($request->sebelah != ""){ $nota = $nota . ', ' . $request->sebelah; } $cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first(); $marhun = Marhun::on($cawangan['mysql'])->create([ 'kodcaw'=> $kodcaw, 'norujukan'=> $request->norujukan, 't_gadai' => $current->toDateString(), 'bil' => 1, 'marhun' => $request->marhun, 'nota' => $nota, 'karat' => $request->karat, 'berat' => $request->berat_emas, 'harga' => $request->harga, 'n_marhun' => $request->nilai_marhun ]); return response()->json($marhun, 201); } public function update($id, Request $request) { $marhun = Marhun::findOrFail($id); $marhun->update($request->all()); return response()->json($marhun, 200); } public function delete($id) { Marhun::findOrFail($id)->delete(); return response('Deleted Successfully', 200); } }