false]); $json = $http->get($url, ['timeout' => 30])->getBody()->getContents(); if (empty($json)) { return $output; } $parsedown = new Parsedown(); $releases = json_decode($json); foreach ($releases as $release) { if (version_compare($release->tag_name, version('short'), '<=')) { continue; } if ($release->prerelease == true) { continue; } if (empty($release->body)) { continue; } $output .= '

' . $release->tag_name . '

'; $output .= $parsedown->text($release->body); $output .= '
'; } return $output; } public static function latest($modules = []) { // Get data from cache $versions = Cache::get('versions'); if (!empty($versions)) { return $versions; } $info = Info::all(); $versions = []; // Check core first $url = 'core/version/' . $info['akaunting'] . '/' . $info['php'] . '/' . $info['mysql'] . '/' . $info['companies']; $versions['core'] = static::getLatestVersion($url, $info['akaunting']); // Then modules foreach ($modules as $module) { $alias = $module->get('alias'); $version = $module->get('version'); $url = 'apps/' . $alias . '/version/' . $version . '/' . $info['akaunting']; $versions[$alias] = static::getLatestVersion($url, $version); } Cache::put('versions', $versions, Date::now()->addHour(6)); return $versions; } public static function getLatestVersion($url, $latest) { if (!$data = static::getResponseData('GET', $url, ['timeout' => 10])) { return $latest; } if (!is_object($data)) { return $latest; } return $data->latest; } }