adrema/app/Payment/AllpaymentController.php

38 lines
965 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;
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 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([
2022-03-11 20:19:17 +01:00
'year' => 'required|numeric',
2021-07-04 22:32:40 +02:00
]);
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
}
}