mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-07-17 22:35:19 +00:00
Two follow-ups to the Services reorg that landed in 6d1816bd.
**Documents → Document** (singular). Documents/ was the only plural subdir in app/Services/ — every other bucket (Company, Mail, Module, Pdf, Storage, Update, ExchangeRate) was singular. Renaming to Document/ normalizes the whole tree.
**ExchangeRate → Integrations/ExchangeRate**. Introduces Integrations/ as an umbrella for external-service adapter subsystems. Exchange rate providers move in first; AI providers, payment gateways, and any other driver-pattern integrations land as sibling subdirs (Integrations/Ai/, Integrations/Payment/) without another reorg. Integrations/ was chosen over Providers/ to avoid conceptual collision with Laravel's app/Providers/ — 'check the providers' shouldn't be ambiguous.
17 files moved, 21 consumer files rewritten to point at the new namespaces via literal-string replacement (same approach as the previous reorg). 350 tests pass, Pint clean.
47 lines
1.2 KiB
PHP
47 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Pdf;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\Estimate;
|
|
use App\Models\Invoice;
|
|
use App\Models\Payment;
|
|
use App\Services\Document\EstimateService;
|
|
use App\Services\Document\InvoiceService;
|
|
use Illuminate\Http\Request;
|
|
|
|
class DocumentPdfController extends Controller
|
|
{
|
|
public function __construct(
|
|
private readonly InvoiceService $invoiceService,
|
|
private readonly EstimateService $estimateService,
|
|
) {}
|
|
|
|
public function invoice(Request $request, Invoice $invoice)
|
|
{
|
|
if ($request->has('preview')) {
|
|
return $this->invoiceService->getPdfData($invoice);
|
|
}
|
|
|
|
return $invoice->getGeneratedPDFOrStream('invoice');
|
|
}
|
|
|
|
public function estimate(Request $request, Estimate $estimate)
|
|
{
|
|
if ($request->has('preview')) {
|
|
return $this->estimateService->getPdfData($estimate);
|
|
}
|
|
|
|
return $estimate->getGeneratedPDFOrStream('estimate');
|
|
}
|
|
|
|
public function payment(Request $request, Payment $payment)
|
|
{
|
|
if ($request->has('preview')) {
|
|
return view('app.pdf.payment.payment');
|
|
}
|
|
|
|
return $payment->getGeneratedPDFOrStream('payment');
|
|
}
|
|
}
|