예제 #1
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $this->info('Truncate data table');
     Data::truncate();
     $this->info('Searching for feeds');
     $activeProgramsFromDB = ActiveProgram::with('program.feeds')->where('status', 1)->get();
     $fields_wanted_from_config = DaisyconHelper::getDatabaseFieldsToImport();
     if (count($activeProgramsFromDB) > 0) {
         foreach ($activeProgramsFromDB as $activeProgram) {
             if (!empty($activeProgram->program->feeds) || !empty($activeProgram->program->name)) {
                 foreach ($activeProgram->program->feeds as $feed) {
                     $this->info($activeProgram->program->name . ' - ' . $feed->name);
                     $url = $feed->{"feed_link_" . strtolower(Config::get('daisycon.feed_type', 'csv'))} . '&f=' . implode(';', $fields_wanted_from_config) . '&encoding=' . Config::get("daisycon.encoding") . '&general=true' . '&nohtml=' . (Config::get("daisycon.accept_html", false) ? 'false' : 'true');
                     $program_id = $activeProgram->program->program_id;
                     $feed_id = $feed->feed_id;
                     $custom_categorie = $activeProgram->custom_categorie;
                     $this->data->importData($url, $program_id, $feed_id, $custom_categorie);
                 }
             } else {
                 $this->info('Geen feeds en/of programma\'s in de database gevonden...');
                 continue;
             }
         }
     } else {
         return $this->info('Geen active programma\'s in de database gevonden...');
     }
     $this->call('daisycon:fix-data');
     return $this->info('Verwerkt in ' . round(microtime(true) - LARAVEL_START, 2) . ' seconden');
 }