/** * 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'); }
public function run() { ActiveProgram::truncate(); $programs = [43 => array('custom_categorie' => 'zomer'), 110 => array('custom_categorie' => 'zomer'), 170 => array('custom_categorie' => 'zomer'), 191 => array('custom_categorie' => 'zomer'), 192 => array('custom_categorie' => ''), 387 => array('custom_categorie' => 'eindhoven'), 388 => array('custom_categorie' => 'maastricht'), 389 => array('custom_categorie' => 'rotterdam'), 390 => array('custom_categorie' => 'eelde'), 470 => array('custom_categorie' => ''), 694 => array('custom_categorie' => 'zomer'), 764 => array('custom_categorie' => 'zomer'), 864 => array('custom_categorie' => 'zomer'), 1571 => array('custom_categorie' => 'brussel'), 1572 => array('custom_categorie' => 'dusseldorf'), 2929 => array('custom_categorie' => 'schiphol'), 3663 => array('custom_categorie' => 'zomer')]; foreach ($programs as $program => $attr) { ActiveProgram::create(['program_id' => $program, 'status' => 1, 'custom_categorie' => $attr['custom_categorie']]); } $this->command->info('ActiveProgram table seeded!'); }