获取记录编辑的多对多关系计数

I have 3 tables in my DB. Classes,Registrations and pivot table class_registration.

An event has classes and the user can select multiple classes for their registration. So if User A selects Class 1 twice and Class 2 once I save 1 row for each round, i.e 2 rows for Class 1 and 1 row for Class 2.

Classes table has the following fields

id | event_id | name | fees

Registration table has the following fields

id | event_id | user_id | fees | isPaid

Class_Registration pivot table has following fields

id | registration_id | class_id | unitFees

Following is the relationship in registration model

public function classes()
{
    return $this->belongsToMany(Classes::class,'class_registrations','registration_id','class_id');
}

Following is my code for the controller

public function updateRegistration(UpdateRegistrationRequest $request, Registration $registration)
{
    return view('frontend.event.editRegistration',['event' => $registration->eventDetail,'registration' => $registration]);
}

I want to get the count of class in each registration so I can populate the data while editing registration.

Following is the view code

@foreach ($registration->classes as $class)
    <tr>
        <td>{{ $class->name }}</td>
        <td>{{ $class->maxEntry }}</td>
        <td>{{ $class->fees }}</td>
        <td>
            {{ html()->hidden('classes[]',$class->id) }}
            <select name="rounds_{{ $class->id }}" id="rounds" class="form-control" required="required">
                @for($i=0; $i<=10; $i++)
                    <option value="{{$i}}">{{$i}}</option>
                @endfor
             </select>
        </td>
    </tr>
@endforeach

How do I group them by class_id and display the count in the dropdown?