channel = $channel; $this->context = $context; $this->message = $message; $this->data = $data; $this->subject = 'mivita Log'; $this->origin = \Auth::check() ? \Auth::user()->id.' | '.\Auth::user()->email : null; $this->userAgent = request()->header('User-Agent'); $this->occurredAt = now()->format('d.m.Y H:i'); } public function build() { $title = 'Log: '.$this->channel.' '.$this->context; // make Data readable $data = json_encode($this->data, JSON_PRETTY_PRINT); $content = "\n"; $content .= 'Channel: '.$this->channel."\n"; $content .= 'Context: '.$this->context."\n"; if ($this->origin) { $content .= 'From User: '.$this->origin."\n"; } $content .= "\n"; $content .= 'Message: '.$this->message."\n"; $content .= "\n"; $content .= 'Data: '.$data."\n"; $content .= "\n"; $content .= "\n"; $content .= 'Time: '.$this->occurredAt; $content .= "\n"; $content .= $this->userAgent; return $this->view('emails.sys')->with([ 'title' => $title, 'content' => $content, ]); } }