$magloo_sport_id) { $event_id_collector = []; /** * Tornaments */ $url = Nuh::$options['base_url'].'/en/'.$magloo_sport_id.'/prematch/sport'; $data = Curl::load($url); if (is_array($data) or \count($data)) { $ligas = []; foreach ($data as $value) { $tmp = []; if ($value['i'] == $magloo_sport_id) { $tmp['sport'] = $value['n']; $tmp['sport_id'] = $sport_id; foreach ($value['C'] as $key => $val1) { $tmp['country_id'] = $val1['i']; $tmp['country'] = $val1['n']; foreach ($val1['T'] as $key => $val2) { $tmp['group_id'] = $val2['i']; $tmp['group'] = $val2['n']; $ligas[] = $tmp; } } } } foreach ($ligas as $liga) { // 19 => array:6 [ // "sport" => "Basketball" // "sport_id" => 3 // "country_id" => 146 // "country" => "Israel" // "group_id" => 525 // "group" => "Super League" // ] if ($liga['group'] && strpos($liga['group'], 'Simulated') === false) { $sport_id = $liga['sport_id']; $url = Nuh::$options['base_url'].'/en/'.$magloo_sport_id.'/prematch/tournament/'.$liga['group_id'].'/event'; $data = Curl::load($url); if (! count($data)) { return; } foreach ($data as $magloo) { $event = []; $event['event_id'] = (int) $magloo['i']; $event['betradar_id'] = (int) preg_replace('/\D/', '', $magloo['p']); $event['sport_id'] = $sport_id; $event['provider_id'] = Nuh::$options['provider_id']; $event['country_id'] = $liga['country_id']; $event['country'] = $liga['country']; $event['group_id'] = $liga['group_id']; $event['group'] = $liga['group']; $event['starttime'] = Carbon::parse($magloo['dt'])->toDateTimeString(); $teams = explode(' v ', str_replace('|', ' ', $magloo['n'])); $event['home_id'] = $magloo['htId']; $event['home'] = addslashes($teams[0]); $event['away_id'] = $magloo['atId']; $event['away'] = addslashes($teams[1]); FindFixture::find($event); if (isset($event['id'])) { $event_id_collector[] = $event['id']; DB::transaction(function () use ($event, $sport_id) { EventBookmaker::updateOrCreate([ 'event_id' => $event['id'], 'sport_id' => $sport_id, 'bookmaker_id' => Nuh::$options['bookmaker_id'], ], ['in_feed' => 1, 'bmoid' => $event['event_id'], 'starttime' => $event['starttime']]); }, 5); } } } } if ($event_id_collector) { EventBookmaker::whereNotIn('event_id', $event_id_collector)->where('bookmaker_id', Nuh::$options['bookmaker_id'])->update(['in_feed' => 0]); } } } } }