/** * Copies over all the packs from the ATLauncher's API into our database. * * @return void */ public function run() { DB::table('packs')->delete(); $atl_packs = json_decode(file_get_contents('https://api.atlauncher.com/v1/packs/full/all'))->data; foreach ($atl_packs as $pack) { Pack::create(array('name' => $pack->name, 'safeName' => $pack->safeName, 'type' => $pack->type, 'description' => $pack->description, 'supportURL' => $pack->supportURL, 'websiteURL' => $pack->websiteURL)); } }
/** * http://wiki.atlauncher.com/api:pack#get_pack_pack_name * * @return Response */ public function v1Pack($pack) { $item = Pack::where('safeName', $pack)->first(); $versions = array(); $j = 0; foreach ($item->versions as $version) { $dt = new DateTime($version->published); $versions[$j] = array("version" => $version->version, "minecraft" => $version->minecraftVersion, "published" => $dt->format('U'), "__LINK" => ""); $j++; } $data = array("id" => $item->id, "name" => $item->name, "safeName" => $item->safeName, "type" => $item->type, "versions" => $versions, "description" => $item->description, "supportURL" => $item->supportURL, "websiteURL" => $item->websiteURL); return Response::make(json_encode(array("error" => false, "code" => 200, "message" => null, "data" => $data), JSON_PRETTY_PRINT))->header('Content-Type', "application/json"); }