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')) { // Through the service, so the preview gets the same shared data and // the same custom-override resolution as the rendered receipt. This // used to name the built-in view directly, so a preview ignored an // override and rendered with no data at all. return $this->paymentService->getPdfData($payment); } return $payment->getGeneratedPDFOrStream('payment'); } }