<?php

namespace App\Models;

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

class IntegrationLog extends Model
{
    use HasFactory;

    protected $table = 'integration_logs';

    protected $fillable = [
        'message', 'context',
    ];

    protected $casts = [
        'context' => 'array',
    ];

    public static function write(string $message, array $context = []): self
    {
        return static::create([
            'message' => $message,
            'context' => $context,
        ]);
    }
}
