<?php

declare(strict_types=1);

namespace App\Model;

/**
 * 失败消息模型
 *
 * 记录 Consumer 处理失败后发送到错误队列的消息
 *
 * @property int $id
 * @property string $error_id
 * @property string $data_type
 * @property string|null $platform
 * @property int|null $platform_id
 * @property int|null $company_id
 * @property int|null $store_id
 * @property string $error_type
 * @property string $error_message
 * @property int $error_code
 * @property string $error_trace
 * @property array $original_message
 * @property int $retry_count
 * @property string|null $message_id
 * @property \Carbon\Carbon $failed_at
 * @property \Carbon\Carbon $created_at
 */
class FailedMessage extends Model
{
    protected ?string $table = 'failed_messages';

    public bool $timestamps = true;

    public const UPDATED_AT = null;

    protected array $fillable = [
        'error_id', 'data_type', 'platform', 'platform_id',
        'company_id', 'store_id', 'error_type', 'error_message',
        'error_code', 'error_trace', 'original_message',
        'retry_count', 'message_id', 'failed_at',
    ];

    protected array $casts = [
        'id' => 'integer',
        'platform_id' => 'integer',
        'company_id' => 'integer',
        'store_id' => 'integer',
        'error_code' => 'integer',
        'original_message' => 'json',
        'retry_count' => 'integer',
        'failed_at' => 'datetime',
        'created_at' => 'datetime',
    ];
}
