This commit is contained in:
2024-10-18 19:29:44 +05:00
parent 681d87236a
commit 0e436b0680
6 changed files with 149 additions and 3 deletions

View File

@@ -0,0 +1,50 @@
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class FetchLoanHistoryController extends Controller
{
/**
* Fetch loan history
*/
public function index(Request $request)
{
$request->validate([
'passport_serie' => ['required', 'string', 'max:255'],
'passport_id' => ['required', 'string', 'max:255'],
]);
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => 'http://10.3.158.102:9999/api/loan/history/info',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => sprintf('{
"idSeria": "%s",
"idNo": "%s"
}',
$request->passport_serie,
$request->passport_id,
),
CURLOPT_HTTPHEADER => [
'Accept: application/json',
'Content-Type: application/json',
],
]);
$response = curl_exec($curl);
curl_close($curl);
return $response;
}
}