$bwin_sport_id) { $page = 1; /** * BWIN ODDS & BETRADAR ID (per page) */ $base_url = 'https://api.b365api.com/v1/bwin/prematch?token='.config('env.betsapi_token').'&skip_markets=1&page=###page###&sport_id='.$bwin_sport_id; while ($page <= $total) { $url = str_replace('###page###', $page, $base_url); $data = Curl::load($url); $total = round($data['pager']['total'] / $data['pager']['per_page']); if ($debug) { Notice::note("Page: $page \nTotal: $total"); } $page++; if (isset($data['results'])) { foreach ($data['results'] as $event) { $betsapi_id = $event['our_event_id'] ?? 0; $betradar_id = $event['BetRadarId'] ?? 0; $bwin_id = $event['Id'] ?? 0; if ($betradar_id && $betsapi_id) { if ($debug) { Notice::note(["Betsapi ID : $betsapi_id", "Betradar ID : $betradar_id", "Bwin ID : $bwin_id"]); } Event::where('betsapi_id', (int) $betsapi_id)->update(['betradar_id' => $betradar_id, 'bwin_id' => $bwin_id]); Mapper::where('event_id', $betsapi_id)->delete(); } } } } } } }