I have to trigger a mail when student crosses several stages . I have two tables
- studentreward_point_categories and
- student_reward_points.
If any student reaches a stage then need to send a mail. How to get category from db .
Reward point Category table.
If for student_id = 19 have 345 points How to get his reward category. i have tried below code.
$total_point = StudentRewardPoint::where('student_id', $request->student_id)
->sum('points');
if(!empty($total_point)){
return $pointCategory = RewardPointCategory::where('from_value','>=', $total_point)
->where('to_value','<=',$total_point)
->where('status',1)
->first();
}
Using this query I'm not able to get user reward point category.
You are querying it totally wrong!! From my point of view swap your '<=' and '>='
return $pointCategory = RewardPointCategory::where('from_value','<=',$total_point)-
>where('to_value','>=',$total_point)->where('status',1)->first();