code
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace App\Filament\Clusters\Cards\CardOrders\Pages;
|
||||
|
||||
use App\Filament\Clusters\Cards\CardOrders\CardOrderResource;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\ForceDeleteAction;
|
||||
use Filament\Actions\RestoreAction;
|
||||
@@ -15,6 +16,11 @@ class EditCardOrder extends EditRecord
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('save_top')
|
||||
->label(__('filament-panels::resources/pages/edit-record.form.actions.save.label'))
|
||||
->submit(null)
|
||||
->action('save'),
|
||||
|
||||
DeleteAction::make(),
|
||||
ForceDeleteAction::make(),
|
||||
RestoreAction::make(),
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Filament\Clusters\Cards\CardOrders\Tables;
|
||||
|
||||
use App\Modules\CardOrder\Filament\Actions\PayCardOrderAction;
|
||||
use App\Modules\CardOrder\Models\CardOrder;
|
||||
use App\Modules\CardOrder\Repositories\CardOrderRepository;
|
||||
use App\Modules\OrderStatus\Repositories\OrderStatusRepository;
|
||||
@@ -85,28 +86,8 @@ class CardOrdersTable
|
||||
TrashedFilter::make(),
|
||||
])
|
||||
->recordActions([
|
||||
Action::make('card_order_pay')
|
||||
->label(__('Pay'))
|
||||
->icon('heroicon-o-credit-card')
|
||||
->requiresConfirmation()
|
||||
->action(function (CardOrder $record) {
|
||||
$onlinePayment = CardOrderRepository::make()
|
||||
->createOnlinePaymentOrder($record);
|
||||
|
||||
if ($onlinePayment->successful()) {
|
||||
Notification::make()
|
||||
->success()
|
||||
->title('Sending')
|
||||
->send();
|
||||
|
||||
return redirect()->away($onlinePayment->paymentLink());
|
||||
}
|
||||
|
||||
Notification::make()
|
||||
->danger()
|
||||
->title('Could not send')
|
||||
->send();
|
||||
}),
|
||||
PayCardOrderAction::make()
|
||||
->hidden(fn (CardOrder $record) => $record->paid),
|
||||
|
||||
EditAction::make(),
|
||||
])
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\CardOrder\Filament\Actions;
|
||||
|
||||
use App\Modules\CardOrder\Models\CardOrder;
|
||||
use App\Modules\CardOrder\Repositories\CardOrderRepository;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Notifications\Notification;
|
||||
|
||||
class PayCardOrderAction
|
||||
{
|
||||
public static function make(): Action
|
||||
{
|
||||
return Action::make('card_order_pay')
|
||||
->label(__('Pay'))
|
||||
->icon('heroicon-o-credit-card')
|
||||
->requiresConfirmation()
|
||||
->action(function (CardOrder $record) {
|
||||
$onlinePayment = CardOrderRepository::make()
|
||||
->createOnlinePaymentOrder($record);
|
||||
|
||||
if ($onlinePayment->successful()) {
|
||||
Notification::make()
|
||||
->success()
|
||||
->title('Sending')
|
||||
->send();
|
||||
|
||||
return redirect()->away($onlinePayment->paymentLink());
|
||||
}
|
||||
|
||||
Notification::make()
|
||||
->danger()
|
||||
->title('Could not send')
|
||||
->send();
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user