You appear to have a many-to-many relationship between User and Course models; the Complete model may be superfluous. I assume you have a column on the intermediate table which determines whether the User has completed the Course?
Let's assume the intermediate table is named completes and it has a boolean column is_completed:
// Course model
public function users()
{
return $this->belongsToMany(User::class, 'completes')->withPivot('is_completed');
}
// Get all courses with the enrolled users
$courses = Course::with('users')->get();
In the view, you need a nested loop to iterate over the $courses and its users. You can get the is_completed value using the pivot property from the relationship:
<ul>
@foreach($courses as $course)
<li>{{ $course->name }}</li>
<ul>
@foreach($course->users as $user)
{{ $user->name }} - {{ $user->pivot->is_completed ? '✅' : '❌' }}
@endforeach
</ul>
@endforeach
</ul>