Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

janvleugels's avatar

Last 5 evaluations

Hello,

I'm building an app that will be used to evaluate students by different courses.

When I make a new evaluation of a selected course, I want to be able to show the 5 previous evaluations of that course.

I suppose I would need a special scope-like method in my 'Student' model, named 'last5evals' that receives the course id. Then I can call this method in the evaluation view:

$evaluation->student->last5evals($course_id);

That would return an array like {'A','C','A','B','B') which I can show in the view.

Is that possible or it there another way to reach my goal?

Thank you!

0 likes
2 replies
janvleugels's avatar

Does anyone have an answer for this problem? Or an alternative for this issue?

jlrdw's avatar

Order descending and take five.

Please or to participate in this conversation.