39 lines
1009 B
PHP
39 lines
1009 B
PHP
<?php
|
|
|
|
namespace App\Filament\Clusters\Cards\CardOrders\Pages;
|
|
|
|
use App\Filament\Clusters\Cards\CardOrders\CardOrderResource;
|
|
use App\Modules\CardOrder\Repositories\CardOrderRepository;
|
|
use Filament\Resources\Pages\CreateRecord;
|
|
|
|
class CreateCardOrder extends CreateRecord
|
|
{
|
|
protected static string $resource = CardOrderResource::class;
|
|
|
|
/**
|
|
* @return array<Action | ActionGroup>
|
|
*/
|
|
protected function getFormActions(): array
|
|
{
|
|
return [
|
|
$this->getCreateFormAction(),
|
|
$this->getCancelFormAction(),
|
|
];
|
|
}
|
|
|
|
protected function getRedirectUrl(): string
|
|
{
|
|
$defaultUrl = $this->getResource()::getUrl('index');
|
|
|
|
/** @var \App\Modules\CardOrder\Models\CardOrder */
|
|
$record = $this->record;
|
|
|
|
$onlinePayment = CardOrderRepository::make()
|
|
->createOnlinePaymentOrder($record);
|
|
|
|
return $onlinePayment->successful()
|
|
? $onlinePayment->paymentLink()
|
|
: $defaultUrl;
|
|
}
|
|
}
|