wip
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Filament\Clusters\Loans\Loans\Tables;
|
||||
|
||||
use App\Modules\Loan\Filaments\Actions\ShowLoanRemainingAction;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
@@ -31,6 +32,7 @@ class LoansTable
|
||||
//
|
||||
])
|
||||
->recordActions([
|
||||
ShowLoanRemainingAction::make(),
|
||||
EditAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\Loan\Filaments\Actions;
|
||||
|
||||
use App\Modules\Loan\Models\Loan;
|
||||
use App\Modules\Loan\Repositories\LoanRepository;
|
||||
use Filament\Actions\Action;
|
||||
use Illuminate\Contracts\View\View;
|
||||
|
||||
class ShowLoanRemainingAction
|
||||
{
|
||||
public static function make(): Action
|
||||
{
|
||||
return Action::make('show_loan_remaining')
|
||||
->label(__('Show remaining loan'))
|
||||
->icon('heroicon-o-banknotes')
|
||||
->requiresConfirmation(false)
|
||||
->modal()
|
||||
->modalContent(fn (Loan $record): View => LoanRepository::make()->showRemainingLoan($record))
|
||||
->modalFooterActions([]);
|
||||
}
|
||||
}
|
||||
@@ -2,4 +2,71 @@
|
||||
|
||||
namespace App\Modules\Loan\Repositories;
|
||||
|
||||
class LoanRepository {}
|
||||
use App\Modules\Loan\Models\Loan;
|
||||
use App\Modules\Makeable;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class LoanRepository
|
||||
{
|
||||
use Makeable;
|
||||
|
||||
public function showRemainingLoan(Loan $record)
|
||||
{
|
||||
$data = $this->fetchCardBalance(
|
||||
passport_serie: user()->passport_serie(),
|
||||
passport_id: user()->passport_id(),
|
||||
account_number: $record->account_number,
|
||||
);
|
||||
|
||||
info([$data]);
|
||||
|
||||
// return $data->errCode != 0
|
||||
// ? view('module.card-balance::error-response', compact('data'))
|
||||
// : view('module.card-balance::card-balance-modal', compact('data'));
|
||||
|
||||
return view('welcome');
|
||||
}
|
||||
|
||||
public function fetchCardBalance(string $passport_serie, int|string $passport_id, int|string $account_number): object
|
||||
{
|
||||
$curl = curl_init();
|
||||
|
||||
curl_setopt_array($curl, [
|
||||
CURLOPT_URL => 'http://10.3.158.102:9999/api/loaninfo',
|
||||
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",
|
||||
"accountCode": "%s"
|
||||
}
|
||||
',
|
||||
$passport_serie,
|
||||
$passport_id,
|
||||
$account_number,
|
||||
),
|
||||
CURLOPT_HTTPHEADER => [
|
||||
'Authorization: Basic dGJ1c2VyOlFBWndzeDEyMw==',
|
||||
'Content-Type: application/json',
|
||||
'Accept: application/json',
|
||||
],
|
||||
]);
|
||||
|
||||
$response = curl_exec($curl);
|
||||
|
||||
curl_close($curl);
|
||||
|
||||
/** @var object */
|
||||
$safeResponse = Str::isJson($response)
|
||||
? json_decode($response)
|
||||
: emptyClass(errCode: 1, message: 'Connection issue to VP');
|
||||
|
||||
return $safeResponse;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -669,5 +669,6 @@
|
||||
"Loans": "Karzlar",
|
||||
"Loan": "Karz",
|
||||
"Please update your profile": "Profiliňizi doldurmagyňyzy haýyş edýäris",
|
||||
"Pay": "Töle"
|
||||
"Pay": "Töle",
|
||||
"Show remaining loan": "Karz galyndysyny gör"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user