87 lines
2.7 KiB
PHP
87 lines
2.7 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
use Illuminate\Support\Facades\Http;
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
class HomeController extends Controller
|
|
{
|
|
/**
|
|
* Create a new controller instance.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct()
|
|
{
|
|
$this->middleware(['auth','verified']);
|
|
}
|
|
|
|
/**
|
|
* Show the application dashboard.
|
|
*
|
|
* @return \Illuminate\View\View
|
|
*/
|
|
public function index()
|
|
{
|
|
$auth_user = Auth::user();
|
|
// $harga_emas = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') .'/api/harga_emas/')->json();
|
|
|
|
// $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();
|
|
|
|
// $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]);
|
|
|
|
// }
|
|
|
|
$CustomerInfo = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') .'/portal/customer/info',['ic' => $auth_user['icno']]);
|
|
//dd($CustomerInfo)
|
|
|
|
$total = 0.00;
|
|
$sixmonths = 0;
|
|
$bilangan = 0;
|
|
foreach($CustomerInfo['gadai'] as $index=>$gadai)
|
|
{
|
|
$bilangan++;
|
|
$total += $gadai['bakipjm'];
|
|
|
|
if($gadai['tempoh'] >= 6)
|
|
{
|
|
$sixmonths++;
|
|
}
|
|
}
|
|
|
|
$bilanganlelong = 0;
|
|
foreach($CustomerInfo['lelong'] as $index1=>$lelong)
|
|
{
|
|
$bilanganlelong += 1;
|
|
}
|
|
|
|
// $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','bilangan','sixmonths','total','bilanganlelong'));
|
|
}
|
|
}
|