adrema/app/Payment/AllpaymentController.php

39 lines
987 B
PHP
Raw Normal View History

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;
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 01:16:37 +01:00
return \Inertia::render('allpayment/Form');
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) {
$member->createPayment([
2021-07-04 22:32:40 +02:00
'nr' => $request->year,
'subscription_id' => $member->subscription_id,
'status_id' => Status::default(),
]);
}
return redirect()->back()->success('Zahlungen erstellt');
2021-07-04 22:32:40 +02:00
}
}