Esempio n. 1
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     if (!Schema::hasTable('continents')) {
         $this->log("Missing continents table.");
         return false;
     }
     // Get all the continents
     $this->continents = Continent::whereEnabled('yes')->where('slug', '!=', 'vRTraining')->orderBy('name')->get();
     // Loop through available continents
     foreach ($this->continents as $continent) {
         if ($this->option($continent->slug) == false and $this->option('all') == false) {
             continue;
         }
         $this->log("Generating " . $continent->name . " script");
         // Regions
         $this->log('Calculating Hex Regions');
         $regions = $this->json_pretty_print(json_encode($this->getRegions($continent)));
         // Facility + Facility Link data
         $this->log('Fetching Facilities');
         $facilities = $this->json_pretty_print(json_encode($this->getFacilities($continent)));
         // Marker data here
         $carbon = new Carbon\Carbon();
         $data = compact('continent', 'carbon', 'regions', 'facilities');
         $output = View::make('js/continent', $data)->render();
         $file = $this->outputPath . $continent->slug . '.js';
         // if ( file_exists($file) and $this->option('overwrite') == false )
         // 	$file = $this->outputPath.$continent->slug.'-'.$carbon->timestamp.'.js';
         $f = fopen($file, 'w');
         fwrite($f, $output);
         fclose($f);
         $this->log($file . " generated");
     }
 }