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'); } }