code
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Filament\Clusters\Cards\CardOrders\Pages;
|
namespace App\Filament\Clusters\Cards\CardOrders\Pages;
|
||||||
|
|
||||||
use App\Filament\Clusters\Cards\CardOrders\CardOrderResource;
|
use App\Filament\Clusters\Cards\CardOrders\CardOrderResource;
|
||||||
|
use Filament\Actions\Action;
|
||||||
use Filament\Actions\DeleteAction;
|
use Filament\Actions\DeleteAction;
|
||||||
use Filament\Actions\ForceDeleteAction;
|
use Filament\Actions\ForceDeleteAction;
|
||||||
use Filament\Actions\RestoreAction;
|
use Filament\Actions\RestoreAction;
|
||||||
@@ -15,6 +16,11 @@ class EditCardOrder extends EditRecord
|
|||||||
protected function getHeaderActions(): array
|
protected function getHeaderActions(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
Action::make('save_top')
|
||||||
|
->label(__('filament-panels::resources/pages/edit-record.form.actions.save.label'))
|
||||||
|
->submit(null)
|
||||||
|
->action('save'),
|
||||||
|
|
||||||
DeleteAction::make(),
|
DeleteAction::make(),
|
||||||
ForceDeleteAction::make(),
|
ForceDeleteAction::make(),
|
||||||
RestoreAction::make(),
|
RestoreAction::make(),
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Filament\Clusters\Cards\CardOrders\Tables;
|
namespace App\Filament\Clusters\Cards\CardOrders\Tables;
|
||||||
|
|
||||||
|
use App\Modules\CardOrder\Filament\Actions\PayCardOrderAction;
|
||||||
use App\Modules\CardOrder\Models\CardOrder;
|
use App\Modules\CardOrder\Models\CardOrder;
|
||||||
use App\Modules\CardOrder\Repositories\CardOrderRepository;
|
use App\Modules\CardOrder\Repositories\CardOrderRepository;
|
||||||
use App\Modules\OrderStatus\Repositories\OrderStatusRepository;
|
use App\Modules\OrderStatus\Repositories\OrderStatusRepository;
|
||||||
@@ -85,28 +86,8 @@ class CardOrdersTable
|
|||||||
TrashedFilter::make(),
|
TrashedFilter::make(),
|
||||||
])
|
])
|
||||||
->recordActions([
|
->recordActions([
|
||||||
Action::make('card_order_pay')
|
PayCardOrderAction::make()
|
||||||
->label(__('Pay'))
|
->hidden(fn (CardOrder $record) => $record->paid),
|
||||||
->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();
|
|
||||||
}),
|
|
||||||
|
|
||||||
EditAction::make(),
|
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