gruene-seele/app/Mail/MailLog.php
2025-04-01 10:39:21 +02:00

63 lines
No EOL
1.6 KiB
PHP

<?php
namespace App\Mail;
use App\User;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
class MailLog extends Mailable
{
use Queueable, SerializesModels;
protected $channel;
protected $context;
protected $message;
protected $data;
public $subject;
public function __construct($channel, $context, $message, $data)
{
$this->channel = $channel;
$this->context = $context;
$this->message = $message;
$this->data = $data;
$this->subject = 'mivita Log';
}
public function build()
{
$title = 'Log: '.$this->channel.' '.$this->context;
//make Data readable
$this->data = json_encode($this->data, JSON_PRETTY_PRINT);
$content = "";
$content .= "\n";
$content .= "Channel: ".$this->channel."\n";
$content .= "Context: ".$this->context."\n";
if(\Auth::check()){
$content .= "From User: ".\Auth::user()->id." | ".\Auth::user()->email."\n";
}
$content .= "\n";
$content .= "Message: ".$this->message."\n";
$content .= "\n";
$content .= "Data: ".$this->data."\n";
$content .= "\n";
$content .= "\n";
$content .= "Time: ".now()->format("d.m.Y H:i");
$content .= "\n";
$content .= request()->header('User-Agent');
return $this->view('emails.sys')->with([
'title' => $title,
'content' => $content,
]);
}
}