diff --git a/app/Http/Middleware/QueryLogging.php b/app/Http/Middleware/QueryLogging.php index 78861d5b8f48..54ba4cfb3428 100644 --- a/app/Http/Middleware/QueryLogging.php +++ b/app/Http/Middleware/QueryLogging.php @@ -49,8 +49,8 @@ class QueryLogging $time = $timeEnd - $timeStart; //Log::info($request->method() . ' - ' . $request->url() . ": $count queries - " . $time); - if($count > 16) - Log::info($queries); + // if($count > 16) + // Log::info($queries); } } diff --git a/app/Listeners/Invoice/CreateInvoicePdf.php b/app/Listeners/Invoice/CreateInvoicePdf.php index 11e3c6d7c0bf..398804e29118 100644 --- a/app/Listeners/Invoice/CreateInvoicePdf.php +++ b/app/Listeners/Invoice/CreateInvoicePdf.php @@ -41,36 +41,40 @@ class CreateInvoicePdf $invoice = $event->invoice; $path = 'public/' . $invoice->client->client_hash . '/invoices/'; - $file = $path . $invoice->invoice_number . '.pdf'; - - Log::error($file); - //get invoice template + $file_path = $path . $invoice->invoice_number . '.pdf'; + //get invoice design $html = $this->generateInvoiceHtml($invoice->design(), $invoice); //todo - move this to the client creation stage so we don't keep hitting this unnecessarily Storage::makeDirectory($path, 0755); //create pdf - $pdf = $this->makePdf(null,null,$html, $file); - - // $path = Storage::putFile($file, $pdf); + $pdf = $this->makePdf(null,null,$html); + + $path = Storage::put($file_path, $pdf); + - //store pdf - //$path = Storage::putFile('public/' . $path, $this->file); - //$url = Storage::url($path); } - - private function makePdf($header, $footer, $html, $pdf) + /** + * Returns a PDF stream + * + * @param string $header Header to be included in PDF + * @param string $footer Footer to be included in PDF + * @param string $html The HTML object to be converted into PDF + * + * @return string The PDF string + */ + private function makePdf($header, $footer, $html) { return Browsershot::html($html) //->showBrowserHeaderAndFooter() //->headerHtml($header) //->footerHtml($footer) - ->waitUntilNetworkIdle() + ->waitUntilNetworkIdle()->pdf(); //->margins(10,10,10,10) - ->savePdf('test.pdf'); + //->savePdf('test.pdf'); } /** @@ -79,15 +83,15 @@ class CreateInvoicePdf * * @param string $design either the path to the design template, OR the full design template string * @param Collection $invoice The invoice object + * * @return string The invoice string in HTML format */ private function generateInvoiceHtml($design, $invoice) :string { - //swap labels + $data['invoice'] = $invoice; return view($design, $data)->render(); - //return view('pdf.stub', $html)->render(); } }