adrema/app/Payment/PaymentController.php

66 lines
2.0 KiB
PHP
Raw Normal View History

2021-07-04 16:56:07 +02:00
<?php
namespace App\Payment;
use App\Http\Controllers\Controller;
2021-08-22 05:15:56 +02:00
use App\Http\Views\MemberView;
2021-07-04 16:56:07 +02:00
use App\Member\Member;
use App\Member\MemberResource;
2022-02-12 15:33:16 +01:00
use Illuminate\Http\RedirectResponse;
2021-08-22 05:15:56 +02:00
use Illuminate\Http\Request;
2022-02-12 15:33:16 +01:00
use Inertia\Response;
2021-07-04 16:56:07 +02:00
class PaymentController extends Controller
{
2022-02-12 15:33:16 +01:00
public function index(Request $request, Member $member): Response
{
2021-07-04 16:56:07 +02:00
session()->put('menu', 'member');
session()->put('title', "Zahlungen für Mitglied {$member->fullname}");
2022-01-02 12:32:57 +01:00
$payload = app(MemberView::class)->index($request, []);
2021-07-04 16:56:07 +02:00
$payload['single'] = app(MemberView::class)->paymentIndex($member);
2022-02-12 14:47:07 +01:00
return \Inertia::render('member/VIndex', $payload);
2021-07-04 16:56:07 +02:00
}
2022-02-12 15:33:16 +01:00
public function store(Request $request, Member $member): RedirectResponse
{
$member->createPayment($request->validate([
2021-07-04 16:56:07 +02:00
'nr' => 'required|numeric',
'subscription_id' => 'required|exists:subscriptions,id',
'status_id' => 'required|exists:statuses,id',
]));
2021-11-11 22:38:03 +01:00
return redirect()->back();
2021-07-04 16:56:07 +02:00
}
2022-02-12 15:33:16 +01:00
public function edit(Member $member, Request $request, Payment $payment): Response
{
2021-07-04 16:56:07 +02:00
session()->put('menu', 'member');
session()->put('title', "Zahlungen für Mitglied {$member->fullname}");
2022-01-02 12:32:57 +01:00
$payload = app(MemberView::class)->index($request, []);
2021-07-04 16:56:07 +02:00
$payload['single'] = app(MemberView::class)->paymentEdit($member, $payment);
2022-02-12 14:47:07 +01:00
return \Inertia::render('member/VIndex', $payload);
2021-07-04 16:56:07 +02:00
}
2022-02-12 15:33:16 +01:00
public function update(Request $request, Member $member, Payment $payment): RedirectResponse
{
2021-07-04 16:56:07 +02:00
$payment->update($request->validate([
'nr' => 'required|numeric',
'subscription_id' => 'required|exists:subscriptions,id',
'status_id' => 'required|exists:statuses,id',
]));
2021-08-22 05:15:56 +02:00
return redirect()->back();
2021-07-04 16:56:07 +02:00
}
2022-02-12 15:33:16 +01:00
public function destroy(Request $request, Member $member, Payment $payment): RedirectResponse
{
2021-07-04 16:56:07 +02:00
$payment->delete();
2021-08-22 05:15:56 +02:00
return redirect()->back();
2021-07-04 16:56:07 +02:00
}
}