adrema/app/Pdf/MemberPdfController.php

27 lines
628 B
PHP
Raw Permalink Normal View History

2021-07-15 21:17:48 +02:00
<?php
namespace App\Pdf;
use App\Http\Controllers\Controller;
2022-11-07 16:18:11 +01:00
use App\Letter\DocumentFactory;
2021-07-15 21:17:48 +02:00
use App\Member\Member;
2022-02-12 16:44:43 +01:00
use Illuminate\Contracts\Support\Responsable;
2021-07-15 21:17:48 +02:00
use Illuminate\Http\Request;
2022-02-12 01:25:22 +01:00
use Illuminate\Http\Response;
2022-11-07 16:18:11 +01:00
use Zoomyboy\Tex\Tex;
2021-07-15 21:17:48 +02:00
class MemberPdfController extends Controller
{
2022-02-12 16:44:43 +01:00
/**
* @return Response|Responsable
*/
2022-02-12 01:25:22 +01:00
public function __invoke(Request $request, Member $member)
2021-07-15 21:17:48 +02:00
{
2022-11-07 16:18:11 +01:00
$document = app(DocumentFactory::class)->fromSingleRequest($request->type, $member);
2021-07-15 21:17:48 +02:00
2022-11-07 16:18:11 +01:00
return null === $document
2021-07-15 21:17:48 +02:00
? response()->noContent()
2022-11-07 16:18:11 +01:00
: Tex::compile($document);
2021-07-15 21:17:48 +02:00
}
}