ActionLogModel.php 705 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. namespace app\model;
  3. use think\Model;
  4. //请求日志模型
  5. class ActionLogModel extends Model
  6. {
  7. protected $table = 'fc_action_log';
  8. protected $pk = 'id';
  9. protected $autoWriteTimestamp = 'datetime';
  10. // 定义时间戳字段名
  11. protected $createTime = 'addtime';
  12. protected $updateTime = 'updatetime';
  13. //添加一条请求记录
  14. public static function add(string $request_id = '', array $param = [])
  15. {
  16. return self::create([
  17. 'request_id' => $request_id,
  18. 'ipaddr' => request()->ip(),
  19. 'action' => request()->pathinfo(),
  20. 'param' => json_encode($param, JSON_UNESCAPED_UNICODE),
  21. ])->save();
  22. }
  23. }