<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class DiscordLog extends Model
{
    public $timestamps = false;

    protected $fillable = ['type', 'message', 'payload', 'created_at'];

    protected function casts(): array
    {
        return [
            'payload' => 'array',
            'created_at' => 'datetime',
        ];
    }

    public static function record(string $type, string $message, array $payload = []): self
    {
        return static::create([
            'type' => $type,
            'message' => $message,
            'payload' => $payload,
            'created_at' => now(),
        ]);
    }
}
