public function postAddBuild($modpack_id)
 {
     $modpack = Modpack::find($modpack_id);
     if (empty($modpack)) {
         return Redirect::to('modpack/list')->withErrors(new MessageBag(array('Modpack not found')));
     }
     $rules = array("version" => "required", "memory" => "numeric");
     $messages = array('version.required' => "You must enter in the build number.", 'memory.numeric' => "You may enter in numbers only for the memory requirement");
     $validation = Validator::make(Input::all(), $rules, $messages);
     if ($validation->fails()) {
         return Redirect::back()->withErrors($validation->messages());
     }
     $clone = Input::get('clone');
     $build = new Build();
     $build->modpack_id = $modpack->id;
     $build->version = Input::get('version');
     $minecraft = Input::get('minecraft');
     $build->minecraft = $minecraft;
     $build->min_java = Input::get('java-version');
     $build->min_memory = Input::get('memory-enabled') ? Input::get('memory') : 0;
     $build->save();
     Cache::forget('modpack.' . $modpack->slug);
     if (!empty($clone)) {
         $clone_build = Build::find($clone);
         $version_ids = array();
         foreach ($clone_build->modversions as $cver) {
             if (!empty($cver)) {
                 array_push($version_ids, $cver->id);
             }
         }
         $build->modversions()->sync($version_ids);
     }
     return Redirect::to('modpack/build/' . $build->id);
 }
示例#2
0
 public function action_do_addbuild($modpack_id)
 {
     if (empty($modpack_id)) {
         return Redirect::to('modpack');
     }
     $modpack = Modpack::find($modpack_id);
     if (empty($modpack)) {
         return Redirect::to('modpack');
     }
     $rules = array("version" => "required");
     $messages = array('version_required' => "You must enter in the build number.");
     $validation = Validator::make(Input::all(), $rules, $messages);
     if ($validation->fails()) {
         return Redirect::back()->with_errors($validation->errors);
     }
     $clone = Input::get('clone');
     $build = new Build();
     $build->modpack_id = $modpack->id;
     $build->version = Input::get('version');
     $minecraft = explode(':', Input::get('minecraft'));
     $build->minecraft = $minecraft[0];
     $build->minecraft_md5 = $minecraft[1];
     $build->save();
     if (!empty($clone)) {
         $clone_build = Build::find($clone);
         $version_ids = array();
         foreach ($clone_build->modversions as $cver) {
             if (!empty($cver)) {
                 array_push($version_ids, $cver->id);
             }
         }
         $build->modversions()->sync($version_ids);
     }
     return Redirect::to('modpack/build/' . $build->id);
 }
示例#3
0
 private function getModpackBuilds($modpack, $details)
 {
     foreach ($details['builds'] as $version => $data) {
         $build = Build::where('version', '=', $version)->first();
         if (empty($build)) {
             $build = new Build();
             $build->modpack_id = $modpack->id;
             $build->version = $version;
             $build->minecraft = $data['minecraft'];
             if (isset($data['forge'])) {
                 $build->forge = $data['forge'];
             }
             $build->save();
         } else {
             $build->minecraft = $data['minecraft'];
             if (isset($data['forge'])) {
                 $build->forge = $data['forge'];
             }
             $build->save();
         }
         if (!$this->getBuildMods($build, $data['mods'])) {
             return false;
         }
     }
     return true;
 }