本文整理汇总了PHP中Build::with方法的典型用法代码示例。如果您正苦于以下问题:PHP Build::with方法的具体用法?PHP Build::with怎么用?PHP Build::with使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Build
的用法示例。
在下文中一共展示了Build::with方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fetchBuild
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;
}