wip
This commit is contained in:
@@ -2,21 +2,15 @@
|
||||
|
||||
namespace App\Nova\Resources\Order\Card\CardBalance\Actions;
|
||||
|
||||
use App\Nova\Resources\Order\Card\CardTransaction\Actions\DownloadCardTransaction;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Blade;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Str;
|
||||
use Laravel\Nova\Actions\Action;
|
||||
use Laravel\Nova\Actions\ActionResponse;
|
||||
use Laravel\Nova\Fields\ActionFields;
|
||||
use Laravel\Nova\Fields\Date;
|
||||
use Laravel\Nova\Http\Requests\NovaRequest;
|
||||
use Markwalet\NovaModalResponse\ModalResponse;
|
||||
use Mpdf\Mpdf;
|
||||
|
||||
class DownloadCardBalance extends Action
|
||||
{
|
||||
@@ -34,7 +28,7 @@ class DownloadCardBalance extends Action
|
||||
* Perform the action on the given models.
|
||||
*
|
||||
* @param \Laravel\Nova\Fields\ActionFields $fields
|
||||
* @param \Illuminate\Support\Collection $models
|
||||
* @param \Illuminate\Support\Collection<array-key, \Illuminate\Database\Eloquent\Model> $models
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(ActionFields $fields, Collection $models)
|
||||
@@ -49,20 +43,24 @@ class DownloadCardBalance extends Action
|
||||
return ActionResponse::danger($data->message);
|
||||
}
|
||||
|
||||
return Action::modal('modal-response', [
|
||||
'title' => __('Card balance'),
|
||||
'html' => Blade::render(
|
||||
file_get_contents(app_path('Nova/Resources/Order/Card/CardBalance/Views/card-balance.blade.php')),
|
||||
['data' => $data]
|
||||
)
|
||||
info([
|
||||
'data' => $data,
|
||||
]);
|
||||
|
||||
// return Action::modal('modal-response', [
|
||||
// 'title' => __('Card balance'),
|
||||
// 'html' => Blade::render(
|
||||
// file_get_contents(app_path('Nova/Resources/Order/Card/CardBalance/Views/card-balance.blade.php')),
|
||||
// ['data' => $data]
|
||||
// ),
|
||||
// ]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the fields available on the action.
|
||||
*
|
||||
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
|
||||
* @return array
|
||||
* @return array<int, \Laravel\Nova\Fields\Field>
|
||||
*/
|
||||
public function fields(NovaRequest $request)
|
||||
{
|
||||
@@ -72,20 +70,38 @@ class DownloadCardBalance extends Action
|
||||
/**
|
||||
* Fetch api
|
||||
*
|
||||
* @param \App\Models\Order\Card\Requisite\CardRequisite $model
|
||||
* @param \App\Models\Order\Card\CardBalance\CardBalance $model
|
||||
*/
|
||||
public function fetchApi($model)
|
||||
public function fetchApi($model): object
|
||||
{
|
||||
$date = today()->format('d.m.Y');
|
||||
|
||||
$response = DownloadCardTransaction::make()->fetchApi(
|
||||
passport_serie: $model->passport_serie,
|
||||
passport_id: $model->passport_id,
|
||||
card_number_masked: Str::mask($model->card_number, '*', 6, 6),
|
||||
card_expire_date: $model->card_month.'/'.substr($model->card_year, 2),
|
||||
start_date: $date,
|
||||
end_date: $date,
|
||||
);
|
||||
$curl = curl_init();
|
||||
curl_setopt_array($curl, [
|
||||
CURLOPT_URL => 'http://10.3.158.102:9999/api/clientinfo/all',
|
||||
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", "cardMaskNumber": "%s", "expDate": "%s" }',
|
||||
$model->passport_serie,
|
||||
$model->passport_id,
|
||||
Str::mask($model->card_number, '*', 6, 6),
|
||||
$model->card_month.'/'.substr($model->card_year, 2)
|
||||
),
|
||||
CURLOPT_HTTPHEADER => [
|
||||
'Authorization: Basic dGJ1c2VyOlFBWndzeDEyMw==',
|
||||
'Content-Type: application/json',
|
||||
],
|
||||
]);
|
||||
|
||||
$response = curl_exec($curl);
|
||||
|
||||
curl_close($curl);
|
||||
|
||||
return Str::isJson($response)
|
||||
? json_decode($response)
|
||||
|
||||
Reference in New Issue
Block a user