invitation = $invitation; $this->quote = $invitation->quote; $this->company = $invitation->company; $this->contact = $invitation->contact; $this->disk = $disk ?? config('filesystems.default'); } public function handle() { $this->quote->load('client'); App::setLocale($this->contact->preferredLocale()); $path = $this->quote->client->quote_filepath(); $quote_design_id = $this->quote->design_id ? $this->quote->design_id : $this->decodePrimaryKey($this->quote->client->getSetting('quote_design_id')); $design = Design::find($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); $html = (new HtmlEngine($designer, $this->invitation, 'quote'))->build(); $pdf = $this->makePdf(null, null, $html); $file_path = $path . $this->quote->number . '.pdf'; $instance = Storage::disk($this->disk)->put($file_path, $pdf); return $file_path; } }