add jenis emas and lelong api

This commit is contained in:
Zakwan Hamdan
2020-11-01 08:45:53 +08:00
parent 508270157c
commit 2486f10ff7
7 changed files with 167 additions and 20 deletions
+48 -3
View File
@@ -6,6 +6,8 @@ use App\Gadai;
use App\Cawangan;
use Illuminate\Http\Request;
use Carbon\Carbon;
class GadaiController extends Controller
{
@@ -36,7 +38,20 @@ class GadaiController extends Controller
return response()->json($gadai_all);
}
public function showOneGadaibyRujukan($kodcaw,$norujukan)
public function showOneGadaiByNorujukan($norujukan){
$cawangan_all = Cawangan::on('mysql7')->get();
$gadai_all = [];
foreach($cawangan_all as $index=>$cawangan){
$gadai = Gadai::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->get();
if(sizeof($gadai) != 0){
array_push($gadai_all,$gadai);
}
}
return response()->json($gadai_all);
}
public function showOneGadaibyRujukanAndCawangan($kodcaw,$norujukan)
{
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
$gadai = Gadai::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->get();
@@ -44,10 +59,40 @@ class GadaiController extends Controller
return response()->json($gadai);
}
public function create(Request $request)
public function create($kodcaw,Request $request)
{
$gadai = Gadai::create($request->all());
$current = Carbon::now();
$current = new Carbon();
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
$gadai = Gadai::on($cawangan['mysql'])->create([
'kodcaw'=>$kodcaw,
'norujukan' => $request->norujukan,
'nopelanggan' => $request->nopelanggan,
'nokp' => $request->nokp,
't_gadai' => $current->toDateString(),
'masa' =>$current->toTimeString(),
'nilaimarhun' => $request->nilaimarhun,
'n_marhuns' => $request->nilaimarhun,
'berat' => $request->berat,
'pinjaman' => $request->pinjaman,
'kadarupah' => $request->kadarupah,
'tempoh' => 6,
't_matang' => $current->addMonths(6)->subDays(1),
'sttebus' => '',
'marhun' => $request->marhun,
'jantina' => $request->jantina,
'bangsa' => $request->bangsa,
'jenistebus' => '',
'penilai' => 'AFIQ',
'namapenilai' => 'Afiq',
'namapelulus' => 'Afiq',
'percentpinj' => $request->percentpinj,
'namateller' => 'Afiq',
'tagpalsu' => 0,
'tellernew' => '',
'tagcall' => ''
]);
return response()->json($gadai, 201);
}
+10 -1
View File
@@ -9,7 +9,16 @@ class HargaEmasController extends Controller
{
public function showAllHargaEmas()
{
return response()->json(HargaEmas::all());
return response()->json(HargaEmas::on('mysql7')->orderby('recno')->get());
}
public function getOneHargaEmas($karat){
$karat_string = str_replace('-','.',$karat);
$harga_emas = HargaEmas::on('mysql7')->select('harga2')->where('karat','=',$karat_string)->first();
return response()->json($harga_emas);
}
public function update($id, Request $request)
+14 -3
View File
@@ -3,6 +3,7 @@
namespace App\Http\Controllers;
use App\Lelong;
use App\Cawangan;
use Illuminate\Http\Request;
class LelongController extends Controller
@@ -10,12 +11,22 @@ class LelongController extends Controller
public function showAllLelongs()
{
return response()->json(Lelong::all());
$cawangan_all = Cawangan::on('mysql7')->get();
$lelong_all = [];
foreach ($cawangan_all as $index => $cawangan){
$lelong = Lelong::on($cawangan['mysql'])->get();
if(sizeof($lelong) != 0){
array_push($lelong_all,$lelong);
}
}
return response()->json($lelong_all);
}
public function showOneLelong($id)
public function showAllLelongByCawangan($kodcaw)
{
return response()->json(Lelong::find($id));
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
$lelong = Lelong::on($cawangan['mysql'])->get();
return response()->json($lelong);
}
public function create(Request $request)
+56 -5
View File
@@ -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);
}
+26
View File
@@ -0,0 +1,26 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Jemas extends Model
{
protected $table = 'jemas';
/**
* The attributes that are mass assignable.
*
* @var array
*/
// protected $fillable = [
// ];
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
// protected $hidden = [];
}
+4 -3
View File
@@ -7,15 +7,16 @@ use Illuminate\Database\Eloquent\Model;
class Marhun extends Model
{
protected $table = 'marhun';
public $timestamps = false;
/**
* The attributes that are mass assignable.
*
* @var array
*/
// protected $fillable = [
// ];
protected $fillable = [
'kodcaw','marhun','t_gadai','norujukan','bil','nota','karat','berat','harga','n_marhun'
];
/**
* The attributes excluded from the model's JSON form.
+9 -5
View File
@@ -32,27 +32,31 @@ $router->group(['prefix'=>'api'], function () use ($router){
//Gadai API
$router->get('gadai',['uses'=>'GadaiController@showAllGadais']);
$router->get('gadai/{noic}',['uses'=>'GadaiController@showOneGadai']);
$router->get('gadai/norujukan/{kodcaw}/{norujukan}',['uses'=>'GadaiController@showOneGadaibyRujukan']);
$router->post('gadai',['uses'=>'GadaiController@create']);
$router->get('gadai/norujukan/{norujukan}',['uses'=>'GadaiController@showOneGadaiByNorujukan']);
$router->get('gadai/norujukan/{kodcaw}/{norujukan}',['uses'=>'GadaiController@showOneGadaibyRujukanAndCawangan']);
$router->post('gadai/{kodcaw}',['uses'=>'GadaiController@create']);
$router->delete('gadai/{id}', ['uses' => 'GadaiController@delete']);
$router->put('gadai/{id}', ['uses' => 'GadaiController@update']);
$router->get('gadai/{cawangan_code}/{date}',['uses'=>'GadaiController@gadaiTransactionByCawanganAndDay']);
//Lelong API
$router->get('lelong',['uses'=>'LelongController@showAllLelongs']);
$router->get('lelong/{id}',['uses'=>'LelongController@showOneLelong']);
$router->get('lelong/cawangan/{kodcaw}',['uses'=>'LelongController@showAllLelongByCawangan']);
$router->post('lelong',['uses'=>'LelongController@create']);
$router->delete('lelong/{id}', ['uses' => 'LelongController@delete']);
$router->put('lelong/{id}', ['uses' => 'LelongController@update']);
//Marhun API
$router->get('marhun',['uses'=>'MarhunController@showAllMarhuns']);
$router->get('marhun/{norujukan}',['uses'=>'MarhunController@showOneLelong']);
$router->post('marhun',['uses'=>'MarhunController@create']);
$router->get('marhun/{norujukan}',['uses'=>'MarhunController@showOneMarhun']);
$router->post('marhun/{kodcaw}',['uses'=>'MarhunController@create']);
$router->put('marhun/{id}', ['uses' => 'MarhunController@update']);
$router->get('jemas/{kodcaw}',['uses'=>'MarhunController@getAllJemas']);
//Harga Emas API
$router->get('harga_emas',['uses'=>'HargaEmasController@showAllHargaEmas']);
$router->get('harga_emas/{karat}',['uses'=>'HargaEmasController@getOneHargaEmas']);
$router->put('harga_emas',['uses'=>'HargaEmasController@update']);
//Cawangan API