has('entity') && request()->has('entity_id') && request()->has('body')) { $invoice_design = new Custom((object)request()->input('body')); $entity = ucfirst(request()->input('entity')); $class = "App\Models\\$entity"; $pdf_class = "App\Jobs\\$entity\\Create{$entity}Pdf"; $entity_obj = $class::whereId($this->decodePrimaryKey(request()->input('entity_id')))->company()->first(); if(!$entity_obj) return $this->blankEntity(); $entity_obj->load('client'); $designer = new Designer($entity_obj, $invoice_design, $entity_obj->client->getSetting('pdf_variables'), lcfirst($entity)); $html = $this->generateInvoiceHtml($designer->build()->getHtml(), $entity_obj); $file_path = PreviewPdf::dispatchNow($html, auth()->user()->company()); return response()->download($file_path)->deleteFileAfterSend(true); } return $this->blankEntity(); } private function blankEntity() { return response()->json(['message' => 'Blank Entity not implemented.'], 200); // $invoice_design = new Custom((object)request()->input('body')); // $file_path = PreviewPdf::dispatchNow(request()->input('body'), auth()->user()->company()); // return response()->download($file_path)->deleteFileAfterSend(true); } }