<?php

namespace App\Listeners;

use App\Models\ProjectMailing;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Events\MessageSent;
use Illuminate\Queue\InteractsWithQueue;

class UpdateMailingStatus
{
    /**
     * Create the event listener.
     */
    public function __construct()
    {
        //
    }

    /**
     * Handle the event.
     */
    public function handle(MessageSent $event): void
    {
        if (array_key_exists('mailing' ,$event->data)) {
            ProjectMailing::where('id', $event->data['mailing']['id'])
                ->update(['status' => 'success']);
        }
    }
}
