<?php

namespace App\Models;

use App\Models\BaseModel;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class AppOperationLog extends BaseModel
{
    protected $table = 'app_operation_logs';

    public const CREATED_AT = 'create_time';

    public const UPDATED_AT = 'update_time';

    protected $fillable = [
        'app_id',
        'operation',
        'version_from',
        'version_to',
        'operator_id',
        'result',
        'error_message',
        'detail',
    ];

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

    public function operator(): BelongsTo
    {
        return $this->belongsTo(AdminUser::class, 'operator_id');
    }
}
