<?php

namespace App\Listeners;

use App\Events\CoinLogEvent;

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

    /**
     * Handle the event.
     */
    public function handle(CoinLogEvent $event): void
    {
        $user = $event->user;

        $user->coinLogs()->create([
            'type' => $event->type,
            'coins' => $event->coins,
            'matter' => $event->coinMatter->title(),
        ]);
    }
}
