<?php

namespace App\Listeners;

use App\Events\TicketRepliedByAdmin;
use App\Events\TicketRepliedByClient;
use Illuminate\Support\Facades\Log;

class LogTicketReplied
{
    public function handle($event): void
    {
        if ($event instanceof TicketRepliedByAdmin) {
            Log::info('Ticket replied by admin', [
                'ticket_id' => $event->ticket->id,
                'reply_id' => $event->reply->id,
                'admin_id' => $event->admin->id,
            ]);
        } elseif ($event instanceof TicketRepliedByClient) {
            Log::info('Ticket replied by client', [
                'ticket_id' => $event->ticket->id,
                'reply_id' => $event->reply->id,
                'client_id' => $event->client->id,
            ]);
        }
    }
}
