pluck('id')->toArray(); /** * Grap */ $kontos = ['soccer' => config('env.txodds_betaid1'), 'other' => config('env.txodds_betaid2')]; foreach ($kontos as $authentication) { // code... if ($today) { Nuh::$options['days_from'] = 0; if (now()->between(today(), today()->addHour())) { Nuh::$options['days_to'] = 2; } else { Nuh::$options['days_to'] = 1; } } elseif ($week) { Nuh::$options['days_from'] = 0; Nuh::$options['days_to'] = 6; } for ($i = Nuh::$options['days_from']; $i < Nuh::$options['days_to']; $i++) { $url = "https://xml2.txodds.com/feed/result/xml.php?$authentication&days=$i,1"; $data = Xml::load($url); foreach ($data as $row) { $sport_id = (int) $row->group['spid']; if (in_array($sport_id, $sports)) { $event = [ 'provider_id' => (int) Nuh::$options['provider_id'], 'starttime' => Carbon::createFromDate((string) $row->time)->toDateTimeString(), 'sport_id' => (int) $sport_id, 'home_id' => (int) $row->hteam['id'], 'away_id' => (int) $row->ateam['id'], 'country_id' => (int) $row->group['cnid'], 'group_id' => (int) $row->group['id'], 'competition_group_id' => (int) $row->group['cgid'], ]; Event::updateOrCreate(['id' => (int) $row['id']], $event); $group = [ 'competition_group_id' => (string) $row->group['cgid'], 'sport_id' => (int) $sport_id, 'country_id' => (int) $row->group['cnid'], 'name' => (string) $row->group, ]; Group::updateOrCreate(['id' => (int) $row->group['id']], $group); $compgroup = [ 'sport_id' => (int) $sport_id, 'country_id' => $event['country_id'], 'name' => (string) $row->group['cname'], ]; CompetitionGroup::updateOrCreate(['id' => (int) $row->group['cgid']], $compgroup); $element = [ 'name' => (string) $row->hteam, 'sport_id' => (int) $sport_id, 'country_id' => (int) $row->group['cnid'], ]; Element::updateOrCreate(['id' => (int) $row->hteam['id']], $element); $element_group = [ 'competition_group_id' => (int) $row->group['cgid'], ]; ElementGroup::updateOrCreate(['element_id' => (int) $row->hteam['id'], 'group_id' => (int) $row->group['id']], $element_group); $element = [ 'name' => (string) $row->ateam, 'sport_id' => (int) $sport_id, 'country_id' => (int) $row->group['cnid'], ]; Element::updateOrCreate(['id' => (int) $row->ateam['id']], $element); $element_group = [ 'competition_group_id' => (int) $row->group['cgid'], ]; ElementGroup::updateOrCreate(['element_id' => (int) $row->ateam['id'], 'group_id' => (int) $row->group['id']], $element_group); if ($sport_id == 1) { $total_soccer++; } else { $total_others++; } } } } if ($debug) { Notice::note(now()->toDateString()." - $count events processed", 'g'); } } if ($debug) { Notice::note("Total Soccer - $total_soccer\nTotal Others - $total_others", 'g'); } } }