adrema/app/Pdf/MemberPdfController.php

28 lines
688 B
PHP
Raw Permalink Normal View History

2021-07-15 21:17:48 +02:00
<?php
namespace App\Pdf;
use App\Http\Controllers\Controller;
2023-04-18 22:08:45 +02:00
use App\Invoice\DocumentFactory;
use App\Invoice\Queries\SingleMemberQuery;
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
{
2023-04-18 22:08:45 +02:00
$invoice = app(DocumentFactory::class)->singleInvoice($request->type, new SingleMemberQuery($member));
2021-07-15 21:17:48 +02:00
2023-04-18 22:08:45 +02:00
return null === $invoice
2021-07-15 21:17:48 +02:00
? response()->noContent()
2023-04-18 22:08:45 +02:00
: Tex::compile($invoice);
2021-07-15 21:17:48 +02:00
}
}