Laravel-Mailgun-Webhooks icon indicating copy to clipboard operation
Laravel-Mailgun-Webhooks copied to clipboard

Access Tags from event

Open MACscr opened this issue 3 years ago • 1 comments

Ive tried an observer and event listener and i cant for the life of me access an emails tags when it comes in. The array is always empty. Works fine when i check that same event id from tinker. Are the tags being captured later or something? I need to be able to act based on the associated tag.

<?php

namespace App\Listeners;

use Biegalski\LaravelMailgunWebhooks\Model\MailgunEvent;
use Biegalski\LaravelMailgunWebhooks\Events\CreatedEvent;
use Log;

class MailOpenedBid
{
    /**
     * Create the event listener.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    public function handle(CreatedEvent $entry): void
    {
        $mail = MailgunEvent::find($entry->event->id);
        Log::debug(print_r($mail->tags->toArray(),true));
    }
}
[2022-08-09 00:46:50] local.DEBUG: Array
(
)

MACscr avatar Aug 09 '22 05:08 MACscr

I see it has a custom CreatedEvent event that it triggers, but it really should be triggering at the end of that store function and not right when the event is created. So its relationship data isnt available when the event is triggered. =(

MACscr avatar Aug 09 '22 16:08 MACscr