toDateTimeString())->delete(); if ($debug) { Notice::note("Deleted: $info"); } /************************************************* * SINGLE SOCCER * https://xml2.txodds.com/feed/odds/xml.php?ident=betaid1&passwd=Dy59vpRC&peid=3118930 * SINGLE OTHER ************************************************* * https://xml2.txodds.com/feed/odds/xml.php?ident=betaid2&passwd=Dy59vpRC&peid=3118930 ************************************************* * https://xml2.txodds.com/feed/odds_types.php * BETTYPE IDS 0 3-WAY 1 2-WAY 3 POINTS 4 TOTALS 5 Asian 65536 3-WAY HALF TIME 131072 3 WAY QUARTER TIME 65539 POINTS HALF TIME 131075 POINTS QUARTER TIME 262147 POINTS OVER TIME 65540 TOTALS HALF TIME 131076 TOTALS QUARTER TIME 262148 TOTALS OVER TIME 11534337 GG/NG (both teams to score) 5242880 DOUBLE CHANCE 7340033 TO PROGRESS (to_qualify) 6291457 DRAW NO BET Not used: 65537 2-WAY HALF TIME 327680 3-WAY 2ND HALF 327681 2-WAY 2ND HALF 327683 POINT 2ND HALF 327684 TOTALS 2ND HALF 1048577 GOAL / NO GOAL 2097153 ODD / EVEN 4194304 TOTAL GOALS 8388608 1X2 EURO HANDCIAP 9437188 TOTAL CORNERS 9502724 TOTAL CORNERS 1ST HALF 20971520 3-WAY CORNERS 28311555 HANDICAP SETS 28311556 TOTAL SETS *************************************************/ $debug = Nuh::$options['d'] ?? 0; $echo = Nuh::$options['e'] ?? 0; switch (Nuh::$options['sport_id']) { case 1: $markets = '0,4,11534337,5242880,7340033,6291457'; break; case 2: // needs check $markets = '0,1,3,4,262148,131072,131076'; break; case 3: // needs check $markets = '0,1,3,4,262147,262148,65539,65540,131075,131076'; break; case 5: $markets = '1,3,4'; break; case 8: $markets = '0,3,4'; break; default: Notice::note('sport not defined', 'r', 1); break; } /************************************************* * URL *************************************************/ $url = 'https://xml2.txodds.com/feed/odds/xml.php?'.Nuh::$AUTHTOKEN.'&all_odds=2&spid='.Nuh::$options['sport_id']; $_calls = []; if (Nuh::$options['event_id']) { $_calls[] = $url."&ot=$markets&peid=".Nuh::$options['event_id']; } elseif (Nuh::$options['a']) { $res = Event::where('starttime', '>', Carbon::now()->toDateTimeString())->pluck('id'); foreach ($res as $id) { $_calls[] = $url."&ot=$markets&peid=".$id; } } elseif (Nuh::$options['w']) { $res = Event::where('starttime', '>', Carbon::now()->toDateTimeString())->where('starttime', '<', Carbon::now()->addDays(7)->toDateTimeString())->pluck('id'); foreach ($res as $id) { $_calls[] = $url."&ot=$markets&peid=".$id; } } else { $_calls[] = $url."&ot=$markets&last=".Nuh::$options['lastcall']; } /************************************************* * CALL *************************************************/ $counter = 0; foreach ($_calls as $url) { $data = Xml::load($url); if ($echo) { dd($data); } if ($debug) { Notice::note('call counter: '.$counter, 'g'); } 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::firstOrCreate(['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); $counter++; foreach ($row->bookmaker as $book) { Nuh::$id = (int) $row['id']; Nuh::$bookmaker_id = (int) $book['bid']; $odds = []; $odds['sport_id'] = (int) $event['sport_id']; $odds['flag'] = 1; $odds['provider_id'] = Nuh::$options['provider_id']; $odds['nuh_check'] = 0; $odds['last_check_at'] = Carbon::now()->toDateTimeString(); foreach ($book->offer as $offer) { $bettypeid = 0; foreach ($offer->attributes() as $attributeName => $attributeValue) { switch ($attributeName) { case 'id': $odds['offer_id'] = (int) $attributeValue; break; case 'ot': $bettypeid = (int) $attributeValue; break; case 'bmoid': $odds['bmoid'] = (string) $attributeValue; break; case 'last_updated': $odds['source_updated_at'] = Carbon::createFromDate((string) $attributeValue)->toDateTimeString(); break; } } switch ($bettypeid) { case 0: _3Way::grap($odds, $offer); break; case 4: _Totals::grap($odds, $offer); break; case 5242880: _Dc::grap($odds, $offer); break; case 6291457: _Dnb::grap($odds, $offer); break; case 11534337: _Ggng::grap($odds, $offer); break; case 7340033: _Tq::grap($odds, $offer); break; default: Notice::note('ERROR Bettype ID not set: '.$bettypeid, 'r'); break; } } } } } if ($debug) { Notice::note('DONE - EVENTS: '.$counter, 'g'); } } }