user = $user; $this->packingList = $packingList; } public function toMail() { $invoice = $this->packingList->transactions()->where('type', TransactionType::SHIPPING_INVOICE)->where('status', ApprovalStatus::APPROVED)->first(); $invoiceDocument = $invoice->documents()->first()->files; return (new MailMessage) ->subject('Att: '.$this->user->name.' - Invoice for order no.'. $this->packingList->owner->reference) ->attach(Storage::disk('documents')->get($invoiceDocument->file->file_info->original->file), [ 'as' => 'name.pdf', 'mime' => 'application/pdf', ])->view('emails.shipment.invoice', ['user' => $this->user, 'packingList' => $this->packingList]); } }