<?php namespace app\model; use think\Model; //请求日志模型 class ActionLogModel extends Model { protected $table = 'fc_action_log'; protected $pk = 'id'; protected $autoWriteTimestamp = 'datetime'; // 定义时间戳字段名 protected $createTime = 'addtime'; protected $updateTime = 'updatetime'; //添加一条请求记录 public static function add(string $request_id = '', array $param = []) { return self::create([ 'request_id' => $request_id, 'ipaddr' => request()->ip(), 'action' => request()->pathinfo(), 'param' => json_encode($param, JSON_UNESCAPED_UNICODE), ])->save(); } }