card transactions working
This commit is contained in:
@@ -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(''),
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -51,12 +50,11 @@ class CardTransactionRepository
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -102,7 +100,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}");
|
||||||
|
|||||||
Reference in New Issue
Block a user