41 lines
1.6 KiB
PHP
41 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use Illuminate\Http\Request;
|
|
use App\Services\CustomerService;
|
|
use Illuminate\Support\Facades\Session;
|
|
use Illuminate\Support\Facades\Http;
|
|
use Illuminate\Support\Facades\Auth;
|
|
use Carbon\Carbon;
|
|
|
|
class GadaianController extends Controller
|
|
{
|
|
public function __construct()
|
|
{
|
|
$this->middleware('auth');
|
|
$this->customerService = New CustomerService();
|
|
}
|
|
|
|
public function index(Request $request)
|
|
{
|
|
$current = Carbon::now();
|
|
$current = new Carbon();
|
|
$curent_year = substr($current->year,2,2);
|
|
$curent_month = sprintf("%02d", $current->month);
|
|
$current_day = sprintf("%02d", $current->day);
|
|
// dd($current_day);
|
|
$noic = $request->noic;
|
|
$customers_info = Http::get(config('api.url') . '/api/customers/'. $noic)->json();
|
|
$customer_info = $customers_info[0];
|
|
// $limit_pinjaman_semasa = $customer_info['limit_pinjaman'] - $customer_info['pinjaman_semasa'];
|
|
$limit_pinjaman_semasa = 0;
|
|
$auth_user = Auth::user();
|
|
$gadai_transaction = sizeof(Http::get(config('api.url') . '/api/gadai/'. $auth_user['cawangan'] . '/' . $current->toDateString())->json());
|
|
$new_transaction = sprintf("%04d",$gadai_transaction+1);
|
|
$norujukan = strtoupper($auth_user['cawangan']) . $curent_year . $curent_month . $current_day . '-' .$new_transaction;
|
|
$cawangan_info = Http::get(config('api.url') . '/api/cawangan/'. $auth_user['cawangan'])->json();
|
|
return view('gadaian.index',compact('customer_info','limit_pinjaman_semasa','cawangan_info','norujukan'));
|
|
}
|
|
}
|