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'; $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) { } }