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;
|
2023-10-13 15:48:29 +02:00
|
|
|
use Illuminate\Http\Response;
|
2021-07-04 16:56:07 +02:00
|
|
|
|
|
|
|
class PaymentController extends Controller
|
|
|
|
{
|
2023-10-13 15:48:29 +02:00
|
|
|
public function store(Request $request, Member $member): Response
|
2022-02-12 15:33:16 +01:00
|
|
|
{
|
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();
|
|
|
|
|
2023-10-13 15:48:29 +02:00
|
|
|
return response('');
|
2021-07-04 16:56:07 +02:00
|
|
|
}
|
|
|
|
|
2023-10-13 15:48:29 +02:00
|
|
|
public function update(Request $request, Member $member, Payment $payment): Response
|
2022-02-12 15:33:16 +01:00
|
|
|
{
|
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();
|
|
|
|
|
2023-10-13 15:48:29 +02:00
|
|
|
return response('');
|
2021-07-04 16:56:07 +02:00
|
|
|
}
|
|
|
|
|
2023-10-13 15:48:29 +02:00
|
|
|
public function destroy(Request $request, Member $member, Payment $payment): Response
|
2022-02-12 15:33:16 +01:00
|
|
|
{
|
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();
|
|
|
|
|
2023-10-13 15:48:29 +02:00
|
|
|
return response('');
|
2021-07-04 16:56:07 +02:00
|
|
|
}
|
|
|
|
}
|