Level 41
If it's for a single user, you can just do this:
$user = User::where('id', 1)->first();
$courses = $user->courses()->paginate(10);
@foreach($courses as $course)
{{ $course->name }}
@endforeach
1 like
$user = User::with('courses')->where('id', 1)->first();
Now in my view I did:
@foreach($user->courses as $course)
{{$course->name}} //display other columns
@endforeach
but the challenge is I have more than 40 courses, each user can offer, which just display all on the page,
I was wondering if I can paginate the courses collection... And how will I go about it if possible
Thanks.
Please or to participate in this conversation.