As I am now putting a lot of data in my database I needed to use laravel's paginate. However, it doesn't seem to work in my other query. Is there other way? or what did I do wrong?
My code is shown below
Paginate Working (ExamController)
$exams = Exam::with('users')->where('id',$userID)->paginate(5);
Paginate Not Working (Questions Controller)
$questions = Question::with(['exams','choices'])->where('exam_id', $examID)->paginate(5);
Code to display pagination
{{ $exams->links() }} ---- exams view
{{ $questions->links()}} ---- questions view
Error
Call to undefined method App\Question::links()
View
<div class="card">
<div class="card-body">
@foreach($questions as $index => $questions)
{{$questions}}
@endforeach
</div>
<div class="mt-3 d-flex justify-content-end text-right">
{{$questions->links()}}
</div>
</div>