<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class CallHistory extends Model
{
    use HasFactory;
    protected $guarded = [];

    public static function recordHistory(Call $call, $event_id): void
    {
        $event = Event::query()->where('id', $event_id)->first();

        self::query()->create([
            'call_id' => $call->id,
            'telephone_id' => $call->telephone_id,
            'caller_phone_number' => $call->caller_phone_number,
            'event_id' => $event->id,
            'event_name' => $event->name
        ]);
    }

}
