<?php

namespace app\model;

use think\Model;

class ApiLog extends Model
{
    protected $name = 'api_logs';
    protected $pk = 'id';
    protected $autoWriteTimestamp = true;
    protected $createTime = 'created_at';
    protected $updateTime = false;

    protected $json = ['request_params', 'response_body'];
    protected $jsonAssoc = true;

    /**
     * 关联API密钥
     */
    public function apiKey()
    {
        return $this->belongsTo(ApiKey::class, 'api_key_id');
    }

    /**
     * 关联客户
     */
    public function client()
    {
        return $this->belongsTo(Client::class, 'client_id');
    }
}