所有我想要的是有一个超过缺席次数的if语句,并显示消息。
下面是SQL查询
public function countAbsent()
{
$absent = Attendances::select(DB::raw('count(status)'))
->where('student_id', '=', Auth::user()->id)
->where('status', '=', 'absent')
->where('section_name', 'like', Input::get('section_name'))
->where('subject_code', 'like', Input::get('subject_code'))
->count();
return View::make('student.view_absent')
->with('absent', $absent);
}发布于 2015-04-18 16:54:05
您可以传递另一个变量来查看:
public function countAbsent()
{
$absent = Attendances::select(DB::raw('count(status)'))
->where('student_id', '=', Auth::user()->id)
->where('status', '=', 'absent')
->where('section_name', 'like', Input::get('section_name'))
->where('subject_code', 'like', Input::get('subject_code'))
->count();
$absent_message = 'Students are not exceeding the absence threshold';
$threshold = 10; //whatever you like
if ($absent > $threshold)
{
$absent_message = 'Students are exceeding the absence threshold';
}
return View::make('student.view_absent')
->with('absent', $absent)
->with('absent_message', $absent_message);
}并在视图student.view_absent中回显$absent_message。
https://stackoverflow.com/questions/29711850
复制相似问题