2021-07-04 22:32:40 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Payment;
|
|
|
|
|
|
|
|
use App\Http\Controllers\Controller;
|
|
|
|
use App\Member\Member;
|
|
|
|
use App\Payment\Status;
|
2022-02-12 01:16:37 +01:00
|
|
|
use Illuminate\Http\RedirectResponse;
|
2021-10-30 00:49:36 +02:00
|
|
|
use Illuminate\Http\Request;
|
2022-02-12 01:16:37 +01:00
|
|
|
use Inertia\Response;
|
2021-07-04 22:32:40 +02:00
|
|
|
|
|
|
|
class AllpaymentController extends Controller
|
|
|
|
{
|
2022-02-12 01:16:37 +01:00
|
|
|
public function create(): Response
|
|
|
|
{
|
2021-07-04 22:32:40 +02:00
|
|
|
session()->put('menu', 'member');
|
|
|
|
session()->put('title', 'Rechnungen erstellen');
|
|
|
|
|
2022-02-12 14:57:09 +01:00
|
|
|
return \Inertia::render('allpayment/VForm');
|
2021-07-04 22:32:40 +02:00
|
|
|
}
|
|
|
|
|
2022-02-12 01:16:37 +01:00
|
|
|
public function store(Request $request): RedirectResponse
|
|
|
|
{
|
2021-07-04 22:32:40 +02:00
|
|
|
$request->validate([
|
|
|
|
'year' => 'required|numeric'
|
|
|
|
]);
|
|
|
|
|
|
|
|
foreach (Member::payable()->whereNoPayment($request->year)->get() as $member) {
|
2021-10-30 00:50:03 +02:00
|
|
|
$member->createPayment([
|
2021-07-04 22:32:40 +02:00
|
|
|
'nr' => $request->year,
|
|
|
|
'subscription_id' => $member->subscription_id,
|
|
|
|
'status_id' => Status::default(),
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2021-10-30 00:49:36 +02:00
|
|
|
return redirect()->back()->success('Zahlungen erstellt');
|
2021-07-04 22:32:40 +02:00
|
|
|
}
|
|
|
|
}
|