add jenis emas and lelong api
This commit is contained in:
@@ -3,8 +3,12 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Marhun;
|
||||
use App\Jemas;
|
||||
use App\Cawangan;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
class MarhunController extends Controller
|
||||
{
|
||||
|
||||
@@ -13,15 +17,62 @@ class MarhunController extends Controller
|
||||
return response()->json(Marhun::all());
|
||||
}
|
||||
|
||||
public function showOneMarhun($id)
|
||||
public function showOneMarhun($norujukan)
|
||||
{
|
||||
$marhun = Marhun::where('noRujukan','=',$norujukan)->get();
|
||||
return response()->json($marhun);
|
||||
$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 create(Request $request)
|
||||
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)
|
||||
{
|
||||
$marhun = Marhun::create($request->all());
|
||||
$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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user