private function fetchBuild($slug, $build) { $response = array(); if (Cache::has('modpack.' . $slug) && empty($this->client) && empty($this->key)) { $modpack = Cache::Get('modpack.' . $slug); } else { $modpack = Modpack::where("slug", "=", $slug)->first(); if (empty($this->client) && empty($this->key)) { Cache::put('modpack.' . $slug, $modpack, 5); } } if (empty($modpack)) { return array("error" => "Modpack does not exist"); } $buildpass = $build; if (Cache::has('modpack.' . $slug . '.build.' . $build) && empty($this->client) && empty($this->key)) { $build = Cache::get('modpack.' . $slug . '.build.' . $build); } else { $build = Build::with('Modversions')->where("modpack_id", "=", $modpack->id)->where("version", "=", $build)->first(); if (empty($this->client) && empty($this->key)) { Cache::put('modpack.' . $slug . '.build.' . $buildpass, $build, 5); } } if (empty($build)) { return array("error" => "Build does not exist"); } $response['minecraft'] = $build->minecraft; $response['minecraft_md5'] = $build->minecraft_md5; $response['java'] = $build->min_java; $response['memory'] = $build->min_memory; $response['forge'] = $build->forge; $response['mods'] = array(); if (!Input::has('include')) { if (Cache::has('modpack.' . $slug . '.build.' . $buildpass . 'modversion') && empty($this->client) && empty($this->key)) { $response['mods'] = Cache::get('modpack.' . $slug . '.build.' . $buildpass . 'modversion'); } else { foreach ($build->modversions as $modversion) { $response['mods'][] = array("name" => $modversion->mod->name, "version" => $modversion->version, "md5" => $modversion->md5, "url" => Config::get('solder.mirror_url') . 'mods/' . $modversion->mod->name . '/' . $modversion->mod->name . '-' . $modversion->version . '.zip'); } usort($response['mods'], function ($a, $b) { return strcasecmp($a['name'], $b['name']); }); Cache::put('modpack.' . $slug . '.build.' . $buildpass . 'modversion', $response['mods'], 5); } } else { if (Input::get('include') == "mods") { if (Cache::has('modpack.' . $slug . '.build.' . $buildpass . 'modversion.include.mods') && empty($this->client) && empty($this->key)) { $response['mods'] = Cache::get('modpack.' . $slug . '.build.' . $buildpass . 'modversion.include.mods'); } else { foreach ($build->modversions as $modversion) { $response['mods'][] = array("name" => $modversion->mod->name, "version" => $modversion->version, "md5" => $modversion->md5, "pretty_name" => $modversion->mod->pretty_name, "author" => $modversion->mod->author, "description" => $modversion->mod->description, "link" => $modversion->mod->link, "donate" => $modversion->mod->donatelink, "url" => Config::get('solder.mirror_url') . 'mods/' . $modversion->mod->name . '/' . $modversion->mod->name . '-' . $modversion->version . '.zip'); } usort($response['mods'], function ($a, $b) { return strcasecmp($a['name'], $b['name']); }); Cache::put('modpack.' . $slug . '.build.' . $buildpass . 'modversion.include.mods', $response['mods'], 5); } } else { $request = explode(",", Input::get('include')); if (Cache::has('modpack.' . $slug . '.build.' . $buildpass . 'modversion.include.' . $request) && empty($this->client) && empty($this->key)) { $response['mods'] = Cache::get('modpack.' . $slug . '.build.' . $buildpass . 'modversion.include.' . $request); } else { foreach ($build->modversions as $modversion) { $data = array("name" => $modversion->mod->name, "version" => $modversion->version, "md5" => $modversion->md5); $mod = (array) $modversion->mod; $mod = $mod['attributes']; foreach ($request as $type) { if (isset($mod[$type])) { $data[$type] = $mod[$type]; } } $response['mods'][] = $data; } usort($response['mods'], function ($a, $b) { return strcasecmp($a['name'], $b['name']); }); Cache::put('modpack.' . $slug . '.build.' . $buildpass . 'modversion.include.' . $request, $response['mods'], 5); } } } return $response; }