Additional data in foreach

In my show function in which you can watch every single group, I load all articles with the same tags. And the article with the most votes will be displayed separately at the top. In addition, I indicate the average rating of the items in this group. This is how my function looks like:

public function show($id)
        $group = group::find($id);

            $tagIdArray = $group->tags->pluck('id')->all();

            $mostvotedarticle = Article::where('type', 4)->whereIn('privacy', [1, 3])
                ->whereHas('tags', function($query) use ($tagIdArray) {
                    $query->whereIn('', $tagIdArray);
                }, '>=', count($tagIdArray))

            $articledown = Article::where('status', 1)->whereHas('tags', function($query) use ($tagIdArray) {
                $query->whereIn('', $tagIdArray);
            }, '>=', count($tagIdArray))->downVotesAll()->count();

            $articleup = Article::where('status', 1)->whereHas('tags', function($query) use ($tagIdArray) {
                $query->whereIn('', $tagIdArray);
            }, '>=', count($tagIdArray))->upVotesAll()->count();

            $ratio = null;

            if($articleup + $articledown == 0) {
                $ratio = 0;
            } else {
                $ratio = ($articleup*100)/($articleup + $articledown);

        return view('singlegroup',compact('groups','mostvotedarticle', 'ratio'));

On a overview page, the individual groups are displayed with a foreach loop:

@foreach ($groups as $group)
        <img src="-----load mostvotedarticle that is in this group------" alt="" />
        <div class="progress-bar-primary" style="width:{{$ratio}}%;">

How can I have the mostvotedarticle and group ratings displayed in the foreach loop?

This is my previous index function:

public function index()
        $user = Auth::user();
        $groups = $user->groups()->latest()->with('tags')->paginate(20);

        return view('groups', compact('groups'));