Compare commits
2 Commits
ece23e01f2
...
5edcde1e4c
| Author | SHA1 | Date | |
|---|---|---|---|
| 5edcde1e4c | |||
| 3409849fa3 |
@@ -149,7 +149,9 @@ class CardResource extends Resource
|
|||||||
->beforeOrEqual('today'),
|
->beforeOrEqual('today'),
|
||||||
])
|
])
|
||||||
->openUrlInNewTab()
|
->openUrlInNewTab()
|
||||||
->action(fn (array $data, Card $record, Component $livewire) => CardTransactionRepository::make()->downloadCardTransaction($data, $record, $livewire)),
|
->action(
|
||||||
|
fn (array $data, Card $record, Component $livewire) => CardTransactionRepository::make()->downloadCardTransaction($data, $record, $livewire)
|
||||||
|
),
|
||||||
|
|
||||||
EditAction::make()
|
EditAction::make()
|
||||||
->label(''),
|
->label(''),
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ class CardBalanceRepository
|
|||||||
{
|
{
|
||||||
/** @var \App\Modules\CardBalance\Types\CardBalanceResponse */
|
/** @var \App\Modules\CardBalance\Types\CardBalanceResponse */
|
||||||
$data = $this->fetchCardBalance(
|
$data = $this->fetchCardBalance(
|
||||||
passport_serie: user()->getOption('passport_serie') ?? 'I',
|
passport_serie: user()->passport_serie(),
|
||||||
passport_id: user()->getOption('passport_id') ?? '909090',
|
passport_id: user()->passport_id(),
|
||||||
card_masked: Str::mask($record->number, '*', 6, 6),
|
card_masked: Str::mask($record->number, '*', 6, 6),
|
||||||
card_expire_date: $record->month.'/'.substr($record->year, 2),
|
card_expire_date: $record->month.'/'.substr($record->year, 2),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ namespace App\Modules\CardTransaction\Repositories;
|
|||||||
use App\Modules\Card\Models\Card;
|
use App\Modules\Card\Models\Card;
|
||||||
use App\Modules\Makeable;
|
use App\Modules\Makeable;
|
||||||
use Filament\Notifications\Notification;
|
use Filament\Notifications\Notification;
|
||||||
use Illuminate\Queue\Events\JobRetryRequested;
|
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
use Illuminate\Support\Facades\Blade;
|
use Illuminate\Support\Facades\Blade;
|
||||||
use Illuminate\Support\Facades\File;
|
use Illuminate\Support\Facades\File;
|
||||||
@@ -21,16 +20,16 @@ class CardTransactionRepository
|
|||||||
/**
|
/**
|
||||||
* Download card transaction
|
* Download card transaction
|
||||||
*
|
*
|
||||||
* @param array{start_date: string, end_date: string} $data
|
* @param array<inst, string>|array{start_date: string, end_date: string} $data
|
||||||
*/
|
*/
|
||||||
public function downloadCardTransaction(array $data, Card $record, Component $livewire)
|
public function downloadCardTransaction(array $data, Card $record, Component $livewire): null
|
||||||
{
|
{
|
||||||
$start_date = Carbon::create($data['start_date']);
|
$start_date = new Carbon($data['start_date']);
|
||||||
$end_date = Carbon::create($data['end_date']);
|
$end_date = new Carbon($data['end_date']);
|
||||||
|
|
||||||
$apiResponse = $this->fetchApi(
|
$apiResponse = $this->fetchApi(
|
||||||
passport_serie: user()->getOption('passport_serie') ?? 'I',
|
passport_serie: user()->passport_serie(),
|
||||||
passport_id: user()->getOption('passport_id') ?? '909090',
|
passport_id: user()->passport_id(),
|
||||||
card_number_masked: Str::mask($record->number, '*', 6, 6),
|
card_number_masked: Str::mask($record->number, '*', 6, 6),
|
||||||
card_expire_date: $record->month.'/'.substr($record->year, 2),
|
card_expire_date: $record->month.'/'.substr($record->year, 2),
|
||||||
start_date: $start_date->format('d.m.Y'),
|
start_date: $start_date->format('d.m.Y'),
|
||||||
@@ -48,15 +47,15 @@ class CardTransactionRepository
|
|||||||
->title($response->message)
|
->title($response->message)
|
||||||
->send();
|
->send();
|
||||||
|
|
||||||
return;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$url = $this->handleFiles($record, $response);
|
$url = $this->generateFileUrl($record, $response);
|
||||||
|
|
||||||
// Tell Livewire to open it in a new tab
|
// Tell Livewire to open it in a new tab
|
||||||
$livewire->js("window.open('{$url}', '_blank')");
|
$livewire->js("window.open('{$url}', '_blank')");
|
||||||
|
|
||||||
return;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -102,7 +101,7 @@ class CardTransactionRepository
|
|||||||
*
|
*
|
||||||
* @param \App\Modules\CardTransaction\Types\CardTransactionResponse $response
|
* @param \App\Modules\CardTransaction\Types\CardTransactionResponse $response
|
||||||
*/
|
*/
|
||||||
public function handleFiles(Card $model, object $response): string
|
public function generateFileUrl(Card $model, object $response): string
|
||||||
{
|
{
|
||||||
$unique_folder_name = Str::snake(str_replace(':', '-', $model->created_at->toDateTimeString()));
|
$unique_folder_name = Str::snake(str_replace(':', '-', $model->created_at->toDateTimeString()));
|
||||||
$dir = public_path("files/{$unique_folder_name}");
|
$dir = public_path("files/{$unique_folder_name}");
|
||||||
|
|||||||
@@ -40,4 +40,20 @@ trait UserAdjustments
|
|||||||
{
|
{
|
||||||
return $this->options && array_key_exists($option, $this->options) ? $this->options[$option] : '';
|
return $this->options && array_key_exists($option, $this->options) ? $this->options[$option] : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Passport serie
|
||||||
|
*/
|
||||||
|
public function passport_serie(): string
|
||||||
|
{
|
||||||
|
return (string) $this->getOption('passport_serie');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Passport id
|
||||||
|
*/
|
||||||
|
public function passport_id(): string
|
||||||
|
{
|
||||||
|
return (string) $this->getOption('passport_id');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user