value('has_active_spread'); if ($has_active_spread) { $events = DB::table($table) ->whereIn('bookmaker_id', [auth()->user()->bookmaker_id, auth()->user()->partner_bookmaker_id]) ->where('active_spread', 1) ->get(); } else { $events = DB::table($table) ->whereIn('bookmaker_id', [auth()->user()->bookmaker_id, auth()->user()->partner_bookmaker_id]) ->get(); } $res = []; foreach ($events as $value) { $value = get_object_vars($value); $event_id = $value['event_id']; foreach (['id', 'event_id', 'sport_id', 'bookmaker_id', 'provider_id', 'offer_id', 'bmoid', 'margin', 'flags', 'nuh_check', 'last_updated', 'created_at', 'updated_at'] as $fieldname) { unset($value[$fieldname]); } $res[$event_id][] = $value; } foreach ($res as $event_id => $odds) { if (count($odds) == 2 && array_diff($odds[0], $odds[1])) { $event_ids[] = $event_id; } } } return array_unique($event_ids); } }