This commit is contained in:
hafifierahman
2022-04-18 09:20:10 +08:00
parent c09332063a
commit 67da9779a8
6 changed files with 603 additions and 145 deletions
+74 -31
View File
@@ -32,47 +32,69 @@ Route::get('/forgetpassword', function () {
Route::get('/firsttime', function () {
return view('/includes/login/firsttime');
});
Route::get('/portalhome', function () {
$auth_user = Auth::user();
// Route::get('/portalhome', function () {
// $auth_user = Auth::user();
$harga_emas = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') .'/api/harga_emas/')->json();
// $harga_emas = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') .'/api/harga_emas/')->json();
$hargaemasterdahulu = array();
// $hargaemasterdahulu = array();
foreach($harga_emas as $index=>$harga)
{
$hargaemassandaran = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') .'/api/harga_emas/rekod/sandaran',['karat' => $harga['karat']])->json();
// foreach($harga_emas as $index=>$harga)
// {
// $hargaemassandaran = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') .'/api/harga_emas/rekod/sandaran',['karat' => $harga['karat']])->json();
$percentnaik = (floatval($harga['harga']) - floatval($hargaemassandaran[1]['harga'])) / ($hargaemassandaran[1]['harga']) * 100;
// $percentnaik = (floatval($harga['harga']) - floatval($hargaemassandaran[1]['harga'])) / ($hargaemassandaran[1]['harga']) * 100;
array_push($hargaemasterdahulu,['karat' => $harga['karat'],'hargasemasa' => $harga['harga'], 'hargadahulu' => $hargaemassandaran[1]['harga'],'percent' => $percentnaik]);
// array_push($hargaemasterdahulu,['karat' => $harga['karat'],'hargasemasa' => $harga['harga'], 'hargadahulu' => $hargaemassandaran[1]['harga'],'percent' => $percentnaik]);
}
// }
$CustomerInfo = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') .'/portal/customer/info',['ic' => $auth_user['icno']])->json();
// $CustomerInfo = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') .'/portal/customer/info',['ic' => $auth_user['icno']])->json();
$total = 0.00;
$sixmonths = 0;
$bilangan = 0;
foreach($CustomerInfo['gadai'] as $index=>$gadai)
{
$bilangan++;
$total += $gadai['pinjaman'];
// $total = 0.00;
// $sixmonths = 0;
// $bilangan = 0;
// foreach($CustomerInfo['gadai'] as $index=>$gadai)
// {
// $bilangan++;
// $total += $gadai['pinjaman'];
if($gadai['tempoh'] >= 6)
{
$sixmonths++;
}
}
// if($gadai['tempoh'] >= 6)
// {
// $sixmonths++;
// }
// }
$bilanganlelong = 0;
foreach($CustomerInfo['lelong'] as $index1=>$lelong)
{
$bilanganlelong += 1;
}
// $bilanganlelong = 0;
// foreach($CustomerInfo['lelong'] as $index1=>$lelong)
// {
// $bilanganlelong += 1;
// }
return view('includes.home',compact('hargaemasterdahulu','bilangan','sixmonths','total','bilanganlelong'));
});
// $arraysag = [];
// $belum_tebus = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/customers/'. $auth_user['icno'] . '/gadai/' . 'belum_tebus')->json();
// if(is_array($belum_tebus))
// {
// if(sizeof($belum_tebus) > 0)
// {
// foreach($belum_tebus as $index=>$bt)
// {
// foreach($bt as $index1=>$bet)
// {
// array_push($arraysag,$bet);
// }
// }
// }
// }
// $belum_tebus = $arraysag;
// $api_url = config('api.url');
// return view('includes.home',compact('api_url','hargaemasterdahulu','bilangan','sixmonths','total','bilanganlelong','belumtebus'));
// });
Route::get('/portalprofile', function () {
return view('/includes/profile');
});
@@ -133,7 +155,28 @@ Route::get('/', function () {
$bilanganlelong += 1;
}
return view('includes.home',compact('hargaemasterdahulu','bilangan','sixmonths','total','bilanganlelong'));
$arraysag = [];
$belum_tebus = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/customers/'. $auth_user['icno'] . '/gadai/' . 'belum_tebus')->json();
if(is_array($belum_tebus))
{
if(sizeof($belum_tebus) > 0)
{
foreach($belum_tebus as $index=>$bt)
{
foreach($bt as $index1=>$bet)
{
array_push($arraysag,$bet);
}
}
}
}
$belum_tebus = $arraysag;
$api_url = config('api.url');
return view('includes.home',compact('api_url','hargaemasterdahulu','bilangan','sixmonths','total','bilanganlelong','belum_tebus'));
})->middleware(['auth','verified']);
// Route::get('/home', 'HomeController@index');