Add update for payment
This commit is contained in:
parent
1e74a6055e
commit
9813482741
|
@ -2,16 +2,23 @@
|
|||
|
||||
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\ActionRequest;
|
||||
use Lorisleiva\Actions\Concerns\AsAction;
|
||||
|
||||
class PaymentUpdateAction
|
||||
{
|
||||
use AsAction;
|
||||
use TracksJob;
|
||||
|
||||
public function handle(): void
|
||||
public function handle(Payment $payment, array $attributes): void
|
||||
{
|
||||
$payment->update($attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -19,19 +26,31 @@ class PaymentUpdateAction
|
|||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [];
|
||||
return [
|
||||
'nr' => 'required',
|
||||
'subscription_id' => 'required|exists:subscriptions,id',
|
||||
'status_id' => 'required|exists:statuses,id',
|
||||
];
|
||||
}
|
||||
|
||||
public function asController(Payment $payment, ActionRequest $request): JsonResponse
|
||||
{
|
||||
$this->startJob($payment, $request->validated());
|
||||
|
||||
return response()->json([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
* @param mixed $parameters
|
||||
*/
|
||||
public function getValidationAttributes(): array
|
||||
public function jobState(WithJobState $jobState, ...$parameters): WithJobState
|
||||
{
|
||||
return [];
|
||||
}
|
||||
$member = $parameters[0]->member;
|
||||
|
||||
public function asController(): JsonResponse
|
||||
{
|
||||
return response()->json([]);
|
||||
return $jobState
|
||||
->before('Zahlung für ' . $member->fullname . ' wird aktualisiert')
|
||||
->after('Zahlung für ' . $member->fullname . ' aktualisiert')
|
||||
->failed('Fehler beim Aktualisieren der Zahlung für ' . $member->fullname)
|
||||
->shouldReload(JobChannels::make()->add('member')->add('payment'));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,19 +11,6 @@ use Illuminate\Http\Response;
|
|||
|
||||
class PaymentController extends Controller
|
||||
{
|
||||
public function update(Request $request, Member $member, Payment $payment): Response
|
||||
{
|
||||
$payment->update($request->validate([
|
||||
'nr' => 'required',
|
||||
'subscription_id' => 'required|exists:subscriptions,id',
|
||||
'status_id' => 'required|exists:statuses,id',
|
||||
]));
|
||||
|
||||
ClientMessage::make('Zahlung aktualisiert.')->shouldReload()->dispatch();
|
||||
|
||||
return response('');
|
||||
}
|
||||
|
||||
public function destroy(Request $request, Member $member, Payment $payment): Response
|
||||
{
|
||||
$payment->delete();
|
||||
|
|
Loading…
Reference in New Issue