invitation = $invitation; $this->disk = $disk ?? config('filesystems.default'); } public function handle() { $starttime = microtime(true); MultiDB::setDb($this->invitation->company->db); if ($this->invitation instanceof InvoiceInvitation) { $this->entity = $this->invitation->invoice; $path = $this->invitation->contact->client->invoice_filepath($this->invitation); } elseif ($this->invitation instanceof QuoteInvitation) { $this->entity = $this->invitation->quote; $path = $this->invitation->contact->client->quote_filepath($this->invitation); } elseif ($this->invitation instanceof CreditInvitation) { $this->entity = $this->invitation->credit; $path = $this->invitation->contact->client->credit_filepath($this->invitation); } elseif ($this->invitation instanceof RecurringInvoiceInvitation) { $this->entity = $this->invitation->recurring_invoice; $path = $this->invitation->contact->client->recurring_invoice_filepath($this->invitation); } $file_path = $path.$this->entity->numberFormatter().'.pdf'; // $state = [ // 'template' => $template->elements([ // 'client' => $this->client, // 'entity' => $this->entity, // 'pdf_variables' => (array) $this->company->settings->pdf_variables, // '$product' => $design->design->product, // 'variables' => $variables, // ]), // 'variables' => $variables, // 'options' => [ // 'all_pages_header' => $this->entity->client->getSetting('all_pages_header'), // 'all_pages_footer' => $this->entity->client->getSetting('all_pages_footer'), // ], // 'process_markdown' => $this->entity->client->company->markdown_enabled, // ]; $pdf = (new PdfService($this->invitation))->getPdf(); $endtime = microtime(true); nlog($endtime - $starttime); if ($pdf) { try { Storage::disk($this->disk)->put($file_path, $pdf); } catch (\Exception $e) { throw new FilePermissionsFailure($e->getMessage()); } } return $file_path; } public function failed($e) { } }