quote = $quote; $this->company = $company; $this->contact = $contact; $this->disk = $disk ?? config('filesystems.default'); } public function handle() { MultiDB::setDB($this->company->db); $settings = $this->quote->client->getMergedSettings(); $this->quote->load('client'); if (!$this->contact) { $this->contact = $this->quote->client->primary_contact()->first(); } App::setLocale($this->contact->preferredLocale()); $path = $this->quote->client->quote_filepath(); $design = Design::find($this->decodePrimaryKey($this->quote->client->getSetting('quote_design_id'))); $designer = new Designer($this->quote, $design, $this->quote->client->getSetting('pdf_variables'), 'quote'); //todo - move this to the client creation stage so we don't keep hitting this unnecessarily Storage::makeDirectory($path, 0755); $quote_number = $this->quote->number; $design_body = $designer->build()->getHtml(); $html = $this->generateEntityHtml($designer, $this->quote, $this->contact); //$start = microtime(true); $pdf = $this->makePdf(null, null, $html); //\Log::error("PDF Build time = ". (microtime(true) - $start)); $file_path = $path . $quote_number . '.pdf'; $instance = Storage::disk($this->disk)->put($file_path, $pdf); return $file_path; } }