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

jericopulvera's avatar

Count failed students and display

Hello everyone. I have this table where Per subjects there will be grades, and I want to display how many of the students failed and pass, what is the eloquent code for this?

0 likes
1 reply
athulpraj's avatar

Try this :

$countfails= Student::where('grade','fail')->count();

Please or to participate in this conversation.