Feature: Moving Payment Methods to DB, adding fees, Transaction Updates, Refund Updates, General Updates to Payments
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Core\Order\Filament\Extensions;
|
||||
|
||||
use Filament\Actions\BulkAction;
|
||||
use Filament\Support\Exceptions\Halt;
|
||||
use Filament\Tables\Table;
|
||||
use Lunar\Admin\Support\Extending\BaseExtension;
|
||||
|
||||
/**
|
||||
* Same fix as OrderRefundActionsExtension, applied to the order lines
|
||||
* table's "bulk_refund" toolbar action (Lunar\Admin\...\OrderItemsTable::
|
||||
* getBulkRefundAction()) — see that class's docblock for the underlying
|
||||
* Filament bug (failureNotification()+failure()+halt() never actually
|
||||
* sends the notification, because halt()'s Halt exception is caught before
|
||||
* Filament reaches the code that would send it).
|
||||
*/
|
||||
class OrderItemsTableExtension extends BaseExtension
|
||||
{
|
||||
public function extendTable(Table $table): Table
|
||||
{
|
||||
return $table->toolbarActions(
|
||||
array_map(
|
||||
fn ($action) => $action instanceof BulkAction && $action->getName() === 'bulk_refund'
|
||||
? $this->fixFailureNotification($action)
|
||||
: $action,
|
||||
$table->getToolbarActions(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
private function fixFailureNotification(BulkAction $action): BulkAction
|
||||
{
|
||||
$originalAction = $action->getActionFunction();
|
||||
|
||||
if ($originalAction === null) {
|
||||
return $action;
|
||||
}
|
||||
|
||||
return $action->action(function (array $arguments) use ($action, $originalAction) {
|
||||
try {
|
||||
return $action->evaluate($originalAction, $arguments);
|
||||
} catch (Halt $exception) {
|
||||
$action->sendFailureNotification();
|
||||
|
||||
throw $exception;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user