statement = $statement; $this->filePath = $filePath; $this->isZip = $isZip; } /** * Build the message. * Membangun struktur email dengan attachment statement * * @return $this */ public function build() { $subject = 'Statement Rekening Bank Artha Graha Internasional'; if ($this->statement->is_period_range) { $subject .= " - {$this->statement->period_from} to {$this->statement->period_to}"; } else { $subject .= " - " . \Carbon\Carbon::createFromFormat('Ym', $this->statement->period_from)->locale('id')->isoFormat('MMMM Y'); } $email = $this->subject($subject) ->view('webstatement::statements.email') ->with([ 'statement' => $this->statement, 'accountNumber' => $this->statement->account_number, 'periodFrom' => $this->statement->period_from, 'periodTo' => $this->statement->period_to, 'isRange' => $this->statement->is_period_range, 'requestType' => $this->statement->request_type, 'batchId' => $this->statement->batch_id, 'accounts' => Account::where('account_number', $this->statement->account_number)->first() ]); if ($this->isZip) { $fileName = "{$this->statement->account_number}_{$this->statement->period_from}_to_{$this->statement->period_to}.zip"; $email->attach($this->filePath, [ 'as' => $fileName, 'mime' => 'application/zip', ]); } else { $fileName = "{$this->statement->account_number}_{$this->statement->period_from}.pdf"; $email->attach($this->filePath, [ 'as' => $fileName, 'mime' => 'application/pdf', ]); } return $email; } }