This commit is contained in:
2025-10-28 21:34:51 +05:00
parent 2c323cf1de
commit e68789e467
2 changed files with 14 additions and 10 deletions

View File

@@ -2,13 +2,14 @@
namespace App\Modules\CardTransaction\Repositories;
use App\Modules\CardTransaction\Types\CardTransactionResponse;
use App\Modules\Card\Models\Card;
use App\Modules\Makeable;
use Illuminate\Queue\Events\JobRetryRequested;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
use Livewire\Component;
use Mpdf\Mpdf;
use Mpdf\Output\Destination;
@@ -21,7 +22,7 @@ class CardTransactionRepository
*
* @param array{start_date: string, end_date: string} $data
*/
public function downloadCardTransaction(array $data, Card $record)
public function downloadCardTransaction(array $data, Card $record, Component $livewire)
{
$start_date = Carbon::create($data['start_date']);
$end_date = Carbon::create($data['end_date']);
@@ -44,7 +45,12 @@ class CardTransactionRepository
return view('module.card-transaction::error-response', ['data' => $response]);
}
return redirect($this->handleFiles($record, $response));
$url = $this->handleFiles($record, $response);
// Tell Livewire to open it in a new tab
$livewire->js("window.open('{$url}', '_blank')");
return;
}
/**
@@ -88,8 +94,7 @@ class CardTransactionRepository
/**
* Handles all file stuff
*
* @param Card $model
* @param \App\Modules\CardTransaction\Types\CardTransactionResponse $response
* @param \App\Modules\CardTransaction\Types\CardTransactionResponse $response
*/
public function handleFiles(Card $model, object $response): string
{
@@ -109,7 +114,6 @@ class CardTransactionRepository
* Generate file
*
* @param \App\Modules\CardTransaction\Types\CardTransactionResponse $data
* @param string $fileDest
*/
public function generateFile(object $response, string $fileDest): void
{