Files
kaunter/app/Http/Controllers/GadaianController.php
T
LAPTOP-DGCU80CH\user1 b50b8b5109 'fix'
2020-11-08 15:58:31 +08:00

46 lines
1.8 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 = 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;
$gadai = Http::post(config('api.url').'/api/gadai/'.$auth_user['cawangan'],[
'norujukan' => $norujukan,
'nopelanggan' => $customer_info['nopelanggan'],
'nokp' => $noic
]);
$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'));
}
}