Actually, yes, I do need some kind of example.
I registered Laravel's MessageSending in the EventServiceProvider and point it to Listeners\AuditLog\LogSentMessage where I have access to the $event->message but need to see how to pull the individual data.
Here's my EventServiceProvider:
'Illuminate\Mail\Events\MessageSending' => [
'App\Listeners\AuditLog\LogSentMessage',
],
And here's my LogSentMessage:
<?php
namespace App\Listeners\AuditLog;
use Illuminate\Support\Facades\Log;
class LogSentMessage
{
/**
* Handle the event.
*
* @param Illuminate\Mail\Events\MessageSending $event
* @return void
*/
public function handle($event)
{
Log::info($event->message);
}
}
For now I'm just logging it so I can see the output, but would be saving this to the audit_logs table with the log type (email in this case) user's ID, IP address, User Agent, and then store the relevant information as a JSON object (because I track so much other information it really only records the "thing/person" that performed the action (if any) and what they performed it on (if any), and any additional information goes in a properties column so I can filter the output on the Audit Log page by log type (e.g. user, invitation, order, queue, etc.) which is handled by Vue.
Thanks so much for your help, and Happy New Years!
Edit: Actually, I got it figured out, didn't realize you could do things like:
$event->message->getSubject();
$event->message->getBody();
$event->message->getHeaders();