Add DestroyAction for payment
This commit is contained in:
parent
9813482741
commit
6d4dda869a
|
@ -2,36 +2,41 @@
|
||||||
|
|
||||||
namespace App\Payment\Actions;
|
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\Http\JsonResponse;
|
||||||
use Illuminate\Validation\Rules\In;
|
|
||||||
use Lorisleiva\Actions\Concerns\AsAction;
|
use Lorisleiva\Actions\Concerns\AsAction;
|
||||||
|
|
||||||
class PaymentDestroyAction
|
class PaymentDestroyAction
|
||||||
{
|
{
|
||||||
use AsAction;
|
use AsAction;
|
||||||
|
use TracksJob;
|
||||||
|
|
||||||
public function handle(): void
|
public function handle(Payment $payment): void
|
||||||
{
|
{
|
||||||
|
$payment->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function asController(Payment $payment): JsonResponse
|
||||||
* @return array<string, array<int, string|In>>
|
|
||||||
*/
|
|
||||||
public function rules(): array
|
|
||||||
{
|
{
|
||||||
return [];
|
$this->startJob($payment);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array<string, string>
|
|
||||||
*/
|
|
||||||
public function getValidationAttributes(): array
|
|
||||||
{
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function asController(): JsonResponse
|
|
||||||
{
|
|
||||||
return response()->json([]);
|
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'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Payment;
|
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
|
||||||
use App\Lib\Events\ClientMessage;
|
|
||||||
use App\Member\Member;
|
|
||||||
use Illuminate\Http\RedirectResponse;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Http\Response;
|
|
||||||
|
|
||||||
class PaymentController extends Controller
|
|
||||||
{
|
|
||||||
public function destroy(Request $request, Member $member, Payment $payment): Response
|
|
||||||
{
|
|
||||||
$payment->delete();
|
|
||||||
|
|
||||||
ClientMessage::make('Zahlung gelöscht.')->shouldReload()->dispatch();
|
|
||||||
|
|
||||||
return response('');
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue