card transactions working

This commit is contained in:
2025-10-28 21:39:57 +05:00
parent ece23e01f2
commit 3409849fa3
2 changed files with 5 additions and 5 deletions

View File

@@ -149,7 +149,9 @@ class CardResource extends Resource
->beforeOrEqual('today'),
])
->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()
->label(''),

View File

@@ -5,7 +5,6 @@ namespace App\Modules\CardTransaction\Repositories;
use App\Modules\Card\Models\Card;
use App\Modules\Makeable;
use Filament\Notifications\Notification;
use Illuminate\Queue\Events\JobRetryRequested;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\Facades\File;
@@ -51,12 +50,11 @@ class CardTransactionRepository
return;
}
$url = $this->handleFiles($record, $response);
$url = $this->generateFileUrl($record, $response);
// Tell Livewire to open it in a new tab
$livewire->js("window.open('{$url}', '_blank')");
return;
}
/**
@@ -102,7 +100,7 @@ class CardTransactionRepository
*
* @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()));
$dir = public_path("files/{$unique_folder_name}");