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(''); - } -}