invitation = $invitation; $this->invoice = $invitation->invoice; $this->company = $invitation->company; $this->contact = $invitation->contact; $this->disk = $disk ?? config('filesystems.default'); } public function handle() { App::setLocale($this->contact->preferredLocale()); $path = $this->invoice->client->invoice_filepath(); $file_path = $path . $this->invoice->number . '.pdf'; $invoice_design_id = $this->invoice->design_id ? $this->invoice->design_id : $this->decodePrimaryKey($this->invoice->client->getSetting('invoice_design_id')); $design = Design::find($invoice_design_id); $designer = new Designer($this->invoice, $design, $this->invoice->client->getSetting('pdf_variables'), 'invoice'); $html = (new HtmlEngine($designer, $this->invitation, 'invoice'))->build(); //todo - move this to the client creation stage so we don't keep hitting this unnecessarily Storage::makeDirectory($path, 0755); $pdf = $this->makePdf(null, null, $html); $instance = Storage::disk($this->disk)->put($file_path, $pdf); return $file_path; } }