adrema/app/Payment/SendpaymentController.php

38 lines
943 B
PHP
Raw Normal View History

2021-07-17 18:46:02 +02:00
<?php
namespace App\Payment;
use App\Http\Controllers\Controller;
use App\Pdf\PdfGenerator;
use App\Pdf\PdfRepositoryFactory;
use Illuminate\Http\Request;
use Inertia\Inertia;
use Inertia\Response as InertiaResponse;
class SendpaymentController extends Controller
{
public function create(): InertiaResponse
{
session()->put('menu', 'member');
session()->put('title', 'Rechnungen versenden');
return Inertia::render('sendpayment/Form', [
'links' => app(ActionFactory::class)->allLinks(),
]);
}
public function send(Request $request)
{
2021-07-18 21:38:00 +02:00
$repo = app(PdfRepositoryFactory::class)->forAll($request->type, 'Post');
2021-07-17 18:46:02 +02:00
2021-07-17 19:21:27 +02:00
$pdfFile = app(PdfGenerator::class)->setRepository($repo)->render();
2021-07-18 21:38:00 +02:00
app(PdfRepositoryFactory::class)->afterAll($request->type, 'Post');
2021-07-17 19:21:27 +02:00
2021-07-17 18:46:02 +02:00
return $repo === null
? response()->noContent()
2021-07-17 19:21:27 +02:00
: $pdfFile;
2021-07-17 18:46:02 +02:00
}
}