2021-07-04 16:56:07 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Payment;
|
|
|
|
|
|
|
|
use App\Http\Controllers\Controller;
|
2023-08-15 00:05:45 +02:00
|
|
|
use App\Lib\Events\ClientMessage;
|
2021-07-04 16:56:07 +02:00
|
|
|
use App\Member\Member;
|
2022-02-12 15:33:16 +01:00
|
|
|
use Illuminate\Http\RedirectResponse;
|
2021-08-22 05:15:56 +02:00
|
|
|
use Illuminate\Http\Request;
|
2021-07-04 16:56:07 +02:00
|
|
|
|
|
|
|
class PaymentController extends Controller
|
|
|
|
{
|
2022-02-12 15:33:16 +01:00
|
|
|
public function store(Request $request, Member $member): RedirectResponse
|
|
|
|
{
|
2021-10-30 00:50:03 +02:00
|
|
|
$member->createPayment($request->validate([
|
2023-01-04 12:40:59 +01:00
|
|
|
'nr' => 'required',
|
2021-07-04 16:56:07 +02:00
|
|
|
'subscription_id' => 'required|exists:subscriptions,id',
|
|
|
|
'status_id' => 'required|exists:statuses,id',
|
|
|
|
]));
|
|
|
|
|
2023-08-15 00:05:45 +02:00
|
|
|
ClientMessage::make('Zahlung erstellt.')->shouldReload()->dispatch();
|
|
|
|
|
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 update(Request $request, Member $member, Payment $payment): RedirectResponse
|
|
|
|
{
|
2021-07-04 16:56:07 +02:00
|
|
|
$payment->update($request->validate([
|
2023-01-04 12:40:59 +01:00
|
|
|
'nr' => 'required',
|
2021-07-04 16:56:07 +02:00
|
|
|
'subscription_id' => 'required|exists:subscriptions,id',
|
|
|
|
'status_id' => 'required|exists:statuses,id',
|
|
|
|
]));
|
|
|
|
|
2023-08-15 00:05:45 +02:00
|
|
|
ClientMessage::make('Zahlung aktualisiert.')->shouldReload()->dispatch();
|
|
|
|
|
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();
|
|
|
|
|
2023-08-15 00:05:45 +02:00
|
|
|
ClientMessage::make('Zahlung gelöscht.')->shouldReload()->dispatch();
|
|
|
|
|
2021-08-22 05:15:56 +02:00
|
|
|
return redirect()->back();
|
2021-07-04 16:56:07 +02:00
|
|
|
}
|
|
|
|
}
|