toDateTimeString())->delete(); if ($debug) { Notice::note("Deleted: $info"); } /** * Grap */ for ($i = 0; $i < 30; $i++) { $url = 'https://xml2.txodds.com/feed/result/xml.php?'.Nuh::$AUTHTOKEN.'&date='.$now->toDateString().','.$now->addDays(1)->toDateString(); $data = Xml::load($url); if ($echo) { dd($data); } foreach ($data as $row) { $event = [ 'provider_id' => (int) Nuh::$options['provider_id'], 'starttime' => Carbon::createFromDate((string) $row->time)->toDateTimeString(), 'sport_id' => (int) $row->group['spid'], '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) $row->group['spid'], 'country_id' => (int) $row->group['cnid'], 'name' => (string) $row->group, ]; Group::updateOrCreate(['id' => (int) $row->group['id']], $group); $compgroup = [ 'sport_id' => $event['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) $row->group['spid'], ]; Element::updateOrCreate(['id' => (int) $row->hteam['id']], $element); $element = [ 'name' => (string) $row->ateam, 'sport_id' => (int) $row->group['spid'], ]; Element::updateOrCreate(['id' => (int) $row->ateam['id']], $element); $count++; } if ($debug) { Notice::note($now->toDateString()." - $count events processed", 'g'); } $total += $count; if ($break) { break; } if ($week && $i == 7) { break; } } if ($debug) { Notice::note("Total - $total events processed", 'g'); } } }