/**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('modpacks')->delete();
     $testmodpack = Modpack::create(array('name' => 'TestModpack', 'slug' => 'testmodpack', 'icon' => false, 'icon_md5' => 'fb6582e4d9c9bc208181907ecc108eb1', 'icon_url' => env('SOLDER_MIRROR_URL') . 'resources/default/icon.png', 'logo' => false, 'logo_md5' => 'fb6582e4d9c9bc208181907ecc108eb1', 'logo_url' => env('SOLDER_MIRROR_URL') . 'resources/default/logo.png', 'background' => false, 'background_md5' => 'fb6582e4d9c9bc208181907ecc108eb1', 'background_url' => env('SOLDER_MIRROR_URL') . 'resources/default/background.jpg'));
     DB::table('builds')->delete();
     $testbuild = Build::create(array('modpack_id' => $testmodpack->id, 'version' => '1.0.0', 'minecraft' => '1.7.10', 'minecraft_md5' => 'e6b7a531b95d0c172acb704d1f54d1b3', 'min_java' => '1.7', 'min_memory' => '1024', 'is_published' => true));
     $testbuild->modversions()->attach(1);
 }
 public function index($id, $build_id)
 {
     if (!($build = Build::find($build_id))) {
         return $this->try_($build);
     }
     if (!($institution = Institution::find($build->institution_id))) {
         return $this->try_($institution);
     }
     $config = Grids::make($id)->toIndexConfig($id);
     $config['row-source'] .= '/' . $build_id;
     $config['breadcrumbs'] = [['name' => 'Institutii de tip:' . Institution::categories()[$institution->category_id], 'route' => "institutions_index", 'ids' => ['type' => $institution->category_id]], ['name' => 'Clădirea ' . $build->name, 'route' => 'buildings_index', 'ids' => ['institution_id' => $institution->id, 'id' => 'cladiri']], ['name' => 'Contoare', 'route' => 'counters_index', 'ids' => ['build_id' => $build_id, 'id' => 'contoare']]];
     return $this->show($config + ['other-info' => ['build' => $build]]);
 }
Exemple #3
0
 public function byType($type, $id)
 {
     if (!($cladire = Build::find($id))) {
         return $this->try_($cladire);
     }
     $cladirea = Build::with('counters.bills')->where('id', $id)->first();
     $out = new Collection();
     foreach ($cladirea['counters'] as $k => $contor) {
         foreach ($contor['bills'] as $i => $factura) {
             if ($factura['type_bill'] == $type) {
                 $out->push($factura);
             }
         }
     }
     /* out -> toate facturile pe tipul respectiv */
     $out = $this->sortDateAsc($out);
     $this->out_months = $this->consum_lunar($out);
     $all = $this->out_months;
     $t = array_values($all);
     $first = array_shift($t);
     $data = $first['months'];
     $header = '';
     $content = '';
     $i = 0;
     foreach ($all as $k => $al) {
         $class = $i == 0 ? 'active' : '';
         $i++;
         $header .= view('consum.lunar.tabs.title')->with(['id' => $k, 'class' => $class])->render();
         $content .= view('consum.lunar.tabs.model')->with(['id' => $k, 'data' => $al, 'class' => $class])->render();
     }
     $tabs = view('consum.lunar.tabs.index')->with(['header' => $header, 'content' => $content])->render();
     if (count($all) == 0) {
         return redirect()->back()->withFlashWarning('Nu sunt date suficinte pentru acest tip de raport');
     }
     return $view = view('consum.lunar.index')->with(compact('data', 'chart', 'data', 'tabs', 'all'));
 }
 private function fetchBuild(Request $request, $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 (!$request->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" => env('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 ($request->input('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" => env('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(",", $request->input('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;
 }