'integer', 'account_type' => 'integer', 'belong_id' => 'integer', 'account_id' => 'integer', 'code' => 'integer']; public static function recordLog(RequestInterface $request, mixed $admin, string $flag, mixed $response): bool { $code = 0; $content = ""; if ($response instanceof Response) { $content = $response->getBody()->getContents(); if ($body = json_decode($content, true)) { $code = $body['code'] ?? 200; } } return self::insert([ 'account_type' => $admin['account_type'], 'belong_id' => $admin['belong_id'], 'account_id' => $admin['account_id'], 'username' => $admin['username'], 'create_time' => date("Y-m-d H:i:s"), 'ua' => Ip::ua(), 'ip' => Ip::ip(), 'flag' => $flag, 'title' => Menu::getTitleByCache(strtolower($request->getMethod()), $flag, $admin['account_type']), 'method' => strtolower($request->getMethod()), 'code' => $code, 'request' => json_encode($request->all(), JSON_UNESCAPED_UNICODE), 'response' => $content ]); } public static function list(array $param) { return self::when(isset($param['account_id']) && $param['account_id'], function ($query) use ($param) { $query->where('account_id', $param['account_id']); })->when(isset($param['flag']) && $param['flag'], function ($query) use ($param) { $query->where('flag', $param['flag']); })->select(['log_id', 'username', 'title', 'method', 'flag', 'code', 'ip', 'ua', 'create_time']) ->orderByDesc("log_id") ->paginate((int)$param['limit']); } }