From 6d4dda869a7d6d6fdda8ce8e67a546b2845892ca Mon Sep 17 00:00:00 2001 From: Philipp Lang Date: Mon, 16 Oct 2023 16:39:06 +0200 Subject: [PATCH] Add DestroyAction for payment --- app/Payment/Actions/PaymentDestroyAction.php | 41 +++++++++++--------- app/Payment/PaymentController.php | 22 ----------- 2 files changed, 23 insertions(+), 40 deletions(-) delete mode 100644 app/Payment/PaymentController.php diff --git a/app/Payment/Actions/PaymentDestroyAction.php b/app/Payment/Actions/PaymentDestroyAction.php index a6094e7f..71df2e80 100644 --- a/app/Payment/Actions/PaymentDestroyAction.php +++ b/app/Payment/Actions/PaymentDestroyAction.php @@ -2,36 +2,41 @@ namespace App\Payment\Actions; +use App\Lib\JobMiddleware\JobChannels; +use App\Lib\JobMiddleware\WithJobState; +use App\Lib\Queue\TracksJob; +use App\Payment\Payment; use Illuminate\Http\JsonResponse; -use Illuminate\Validation\Rules\In; use Lorisleiva\Actions\Concerns\AsAction; class PaymentDestroyAction { use AsAction; + use TracksJob; - public function handle(): void + public function handle(Payment $payment): void { + $payment->delete(); } - /** - * @return array> - */ - public function rules(): array + public function asController(Payment $payment): JsonResponse { - return []; - } + $this->startJob($payment); - /** - * @return array - */ - public function getValidationAttributes(): array - { - return []; - } - - public function asController(): JsonResponse - { return response()->json([]); } + + /** + * @param mixed $parameters + */ + public function jobState(WithJobState $jobState, ...$parameters): WithJobState + { + $member = $parameters[0]->member; + + return $jobState + ->before('Zahlung für ' . $member->fullname . ' wird gelöscht') + ->after('Zahlung für ' . $member->fullname . ' gelöscht') + ->failed('Fehler beim Löschen der Zahlung für ' . $member->fullname) + ->shouldReload(JobChannels::make()->add('member')->add('payment')); + } } diff --git a/app/Payment/PaymentController.php b/app/Payment/PaymentController.php deleted file mode 100644 index baf2a029..00000000 --- a/app/Payment/PaymentController.php +++ /dev/null @@ -1,22 +0,0 @@ -delete(); - - ClientMessage::make('Zahlung gelöscht.')->shouldReload()->dispatch(); - - return response(''); - } -}