', Carbon::now()->toDateTimeString())->pluck('txid'); foreach ($res as $id) { $_calls[] = $url."&ot=$markets&peid=".$id; } } elseif (NuhBash::$options['w']) { $res = Event::where('time', '>', Carbon::now()->toDateTimeString())->where('time', '<', Carbon::now()->addDays(7)->toDateTimeString())->pluck('txid'); foreach ($res as $id) { $_calls[] = $url."&ot=$markets&peid=".$id; } } else { $_calls[] = $url.'&last='.NuhBash::$options['lastcall']; } /************************************************* * CALL *************************************************/ foreach ($_calls as $url) { $json_obj = Curl::load($url, $debug); $e = []; foreach ($json_obj['match'] as $key => $v) { Notice::note($key, 'b'); switch ($key) { case '@attributes': $e['id'] = (int) $v['id']; break; case 'time': $e['time'] = $v; break; case 'group': $e['liga'] = $v['@attributes']['cname']; $e['liid'] = $v['@attributes']['id']; $e['cgid'] = $v['@attributes']['cgid']; $e['spid'] = $v['@attributes']['spid']; $e['mgid'] = $v['@attributes']['mgid']; $e['cnid'] = $v['@attributes']['cnid']; break; case 'hteam': $e['hoid'] = $v['@attributes']['id']; $e['home'] = $v['@text']; break; case 'ateam': $e['awid'] = $v['@attributes']['id']; $e['away'] = $v['@text']; break; case 'bookmaker': foreach ($v as $books) { foreach ($books as $bkey => $book) { switch ($bkey) { case '@attributes': $bname = $book['name']; $bkmid = (int) $book['bid']; $e['odds'][$bkmid]['name'] = $bname; break; case 'offer': foreach ($book as $offer) { foreach ($offer as $type => $od) { switch ($type) { case '@attributes': $bettypeid = (int) $od['ot']; dd('add to event bookmaker missing'); // 'book_startime' => $od['@attributes']['starting_time'], $bmoid = $od['bmoid']; break; case 'odds': switch ($bettypeid) { case '0': Odds3way::updateOrCreate( [ 'event_id' => $e['id'], 'bookmaker_id' => $bkmid, 'sport_id' => NuhBash::$options['sport_id'], 'bmoid' => $bmoid, ], [ 'start' => $od['@attributes']['starting_time'], 'h3w' => (float) $od['o1'], 'd3w' => (float) $od['o2'], 'a3w' => (float) $od['o3'], 'margin' => (float) Helper::margin([$od['o1'], $od['o2'], $od['o3']], 1), 'flag' => 1, 'check' => 0, 'source_updated_at' => $od['@attributes']['time'], 'last_check_at' => Carbon::now()->toDateTimeString(), ] ); break; case '1': Odds2way::updateOrCreate( [ 'event_id' => $e['id'], 'bookmaker_id' => $bkmid, 'sport_id' => NuhBash::$options['sport_id'], 'bmoid' => $bmoid, ], [ 'start' => $od['@attributes']['starting_time'], 'h2w' => (float) $od['o1'], 'a2w' => (float) $od['o3'], 'margin' => (float) Helper::margin([$od['o1'], $od['o3']], 1), 'flag' => 1, 'check' => 0, 'source_updated_at' => $od['@attributes']['time'], 'last_check_at' => Carbon::now()->toDateTimeString(), ] ); break; case '4': OddsTotal::updateOrCreate( [ 'event_id' => $e['id'], 'bookmaker_id' => $bkmid, 'sport_id' => NuhBash::$options['sport_id'], 'bmoid' => $bmoid, 'spread' => (float) $od['o3'], ], [ 'start' => $od['@attributes']['starting_time'], 'over' => (float) $od['o1'], 'under' => (float) $od['o2'], 'margin' => (float) Helper::margin([$od['o1'], $od['o2'], $od['o3']], 1), 'flag' => 1, 'check' => 0, 'source_updated_at' => $od['@attributes']['time'], 'last_check_at' => Carbon::now()->toDateTimeString(), ] ); break; case '5242880': OddsDc::updateOrCreate( [ 'event_id' => $e['id'], 'bookmaker_id' => $bkmid, 'sport_id' => NuhBash::$options['sport_id'], 'bmoid' => $bmoid, ], [ 'start' => $od['@attributes']['starting_time'], 'dc1x' => (float) $od['o1'], 'dc12' => (float) $od['o2'], 'dc2x' => (float) $od['o3'], 'margin' => (float) Helper::margin([$od['o1'], $od['o2'], $od['o3']], 1), 'flag' => 1, 'check' => 0, 'source_updated_at' => $od['@attributes']['time'], 'last_check_at' => Carbon::now()->toDateTimeString(), ] ); break; case '11534337': OddsGgng::updateOrCreate( [ 'event_id' => $e['id'], 'bookmaker_id' => $bkmid, 'sport_id' => NuhBash::$options['sport_id'], 'bmoid' => $bmoid, ], [ 'start' => $od['@attributes']['starting_time'], 'gg' => (float) $od['o1'], 'ng' => (float) $od['o3'], 'margin' => (float) Helper::margin([$od['o1'], $od['o3']], 1), 'flag' => 1, 'check' => 0, 'source_updated_at' => $od['@attributes']['time'], 'last_check_at' => Carbon::now()->toDateTimeString(), ] ); break; case '11534337': OddsQualify::updateOrCreate( [ 'event_id' => $e['id'], 'bookmaker_id' => $bkmid, 'sport_id' => NuhBash::$options['sport_id'], 'bmoid' => $bmoid, ], [ 'start' => $od['@attributes']['starting_time'], 'htq' => (float) $od['o1'], 'atq' => (float) $od['o2'], 'margin' => (float) Helper::margin([$od['o1'], $od['o3']], 1), 'flag' => 1, 'check' => 0, 'source_updated_at' => $od['@attributes']['time'], 'last_check_at' => Carbon::now()->toDateTimeString(), ] ); break; } break; } } } break; } } } break; } } } } }