2021-07-17 18:46:02 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Payment;
|
|
|
|
|
|
|
|
use App\Http\Controllers\Controller;
|
2022-12-06 23:11:57 +01:00
|
|
|
use App\Letter\BillKind;
|
2022-11-07 16:18:11 +01:00
|
|
|
use App\Letter\DocumentFactory;
|
2022-12-07 00:40:53 +01:00
|
|
|
use App\Letter\Queries\BillKindQuery;
|
2022-02-12 16:44:43 +01:00
|
|
|
use Illuminate\Contracts\Support\Responsable;
|
2021-07-17 18:46:02 +02:00
|
|
|
use Illuminate\Http\Request;
|
2022-02-12 16:44:43 +01:00
|
|
|
use Illuminate\Http\Response;
|
2021-07-17 18:46:02 +02:00
|
|
|
use Inertia\Inertia;
|
|
|
|
use Inertia\Response as InertiaResponse;
|
2022-11-07 16:18:11 +01:00
|
|
|
use Zoomyboy\Tex\Tex;
|
2021-07-17 18:46:02 +02:00
|
|
|
|
|
|
|
class SendpaymentController extends Controller
|
|
|
|
{
|
|
|
|
public function create(): InertiaResponse
|
|
|
|
{
|
|
|
|
session()->put('menu', 'member');
|
|
|
|
session()->put('title', 'Rechnungen versenden');
|
|
|
|
|
2022-02-12 14:47:07 +01:00
|
|
|
return Inertia::render('sendpayment/VForm', [
|
2021-10-29 21:44:23 +02:00
|
|
|
'types' => app(ActionFactory::class)->allLinks(),
|
2021-07-17 18:46:02 +02:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2022-02-12 16:44:43 +01:00
|
|
|
/**
|
|
|
|
* @return Response|Responsable
|
|
|
|
*/
|
2021-07-17 18:46:02 +02:00
|
|
|
public function send(Request $request)
|
|
|
|
{
|
2022-12-07 00:40:53 +01:00
|
|
|
$letter = app(DocumentFactory::class)->singleLetter($request->type, new BillKindQuery(BillKind::POST));
|
2021-07-17 18:46:02 +02:00
|
|
|
|
2022-12-07 00:40:53 +01:00
|
|
|
if (is_null($letter)) {
|
2022-11-07 16:18:11 +01:00
|
|
|
return response()->noContent();
|
|
|
|
}
|
2021-07-17 19:21:27 +02:00
|
|
|
|
2022-12-07 00:40:53 +01:00
|
|
|
$pdfFile = Tex::compile($letter);
|
|
|
|
app(DocumentFactory::class)->afterSingle($letter);
|
2022-11-07 16:18:11 +01:00
|
|
|
|
|
|
|
return $pdfFile;
|
2021-07-17 18:46:02 +02:00
|
|
|
}
|
|
|
|
}
|