adrema/app/Payment/Actions/PaymentDestroyAction.php

43 lines
1.1 KiB
PHP
Raw Normal View History

2023-10-16 16:21:23 +02:00
<?php
namespace App\Payment\Actions;
2023-10-16 16:39:06 +02:00
use App\Lib\JobMiddleware\JobChannels;
use App\Lib\JobMiddleware\WithJobState;
use App\Lib\Queue\TracksJob;
use App\Payment\Payment;
2023-10-16 16:21:23 +02:00
use Illuminate\Http\JsonResponse;
use Lorisleiva\Actions\Concerns\AsAction;
class PaymentDestroyAction
{
use AsAction;
2023-10-16 16:39:06 +02:00
use TracksJob;
2023-10-16 16:21:23 +02:00
2023-10-16 16:39:06 +02:00
public function handle(Payment $payment): void
2023-10-16 16:21:23 +02:00
{
2023-10-16 16:39:06 +02:00
$payment->delete();
2023-10-16 16:21:23 +02:00
}
2023-10-16 16:39:06 +02:00
public function asController(Payment $payment): JsonResponse
2023-10-16 16:21:23 +02:00
{
2023-10-16 16:39:06 +02:00
$this->startJob($payment);
return response()->json([]);
2023-10-16 16:21:23 +02:00
}
/**
2023-10-16 16:39:06 +02:00
* @param mixed $parameters
2023-10-16 16:21:23 +02:00
*/
2023-10-16 16:39:06 +02:00
public function jobState(WithJobState $jobState, ...$parameters): WithJobState
2023-10-16 16:21:23 +02:00
{
2023-10-16 16:39:06 +02:00
$member = $parameters[0]->member;
2023-10-16 16:21:23 +02:00
2023-10-16 16:39:06 +02:00
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'));
2023-10-16 16:21:23 +02:00
}
}