本文整理汇总了PHP中app\models\Task::whereKcxh方法的典型用法代码示例。如果您正苦于以下问题:PHP Task::whereKcxh方法的具体用法?PHP Task::whereKcxh怎么用?PHP Task::whereKcxh使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Task
的用法示例。
在下文中一共展示了Task::whereKcxh方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: show
/**
* 显示课程学生名单
* @author FuRongxin
* @date 2016-03-18
* @version 2.0
* @param \Illuminate\Http\Request $request 学生名单请求
* @param string $kcxh 12位课程序号
* @return \Illuminate\Http\Response 学生名录列表
*/
public function show(Request $request, $kcxh)
{
$inputs = $request->all();
$year = isset($inputs['year']) ? $inputs['year'] : session('year');
$term = isset($inputs['term']) ? $inputs['term'] : session('term');
$students = Selcourse::whereKcxh($kcxh)->whereNd($year)->whereXq($term)->orderBy('xh')->get();
$task = Task::whereKcxh($kcxh)->whereNd($year)->whereXq($term)->whereJsgh(Auth::user()->jsgh)->firstOrFail();
$title = $task->nd . '年度' . $task->term->mc . '学期' . $task->kcxh . $task->course->kcmc . '课程';
return view('task.show')->withTitle($title . '学生名单')->withStudents($students);
}
示例2: batchUpdate
/**
* 批量更新成绩
* @author FuRongxin
* @date 2016-05-06
* @version 2.1
* @param \Illuminate\Http\Request $request 更新成绩请求
* @param string $kcxh 12位课程序号
* @return \Illuminate\Http\Response 学生成绩
*/
public function batchUpdate(Request $request, $kcxh)
{
if ($request->isMethod('put')) {
$inputs = $request->all();
$snos = array_unique(array_map(function ($val) {
return Str::substr($val, 0, 12);
}, array_filter(array_keys($inputs), function ($val) {
return is_numeric($val);
})));
$task = Task::whereKcxh($kcxh)->whereNd(session('year'))->whereXq(session('term'))->whereJsgh(Auth::user()->jsgh)->firstOrFail();
$ratios = [];
$items = Ratio::whereFs($task->cjfs)->orderBy('id')->get();
foreach ($items as $ratio) {
$ratios[] = ['id' => $ratio->id, 'name' => $ratio->idm, 'value' => $ratio->bl / $ratio->mf, 'allow_failed' => $ratio->jg];
}
foreach ($snos as $sno) {
$student = Score::whereNd(session('year'))->whereXq(session('term'))->whereKcxh($kcxh)->whereXh($sno)->firstOrFail();
$rules = [];
foreach ($items as $item) {
$rules[$student->xh . $item->id] = 'numeric|min:0|max:100';
}
$rules[$student->xh . 'kszt'] = 'numeric';
$this->validate($request, $rules);
foreach ($items as $item) {
$student->{'cj' . $item->id} = isset($inputs[$student->xh . $item->id]) ? $inputs[$student->xh . $item->id] : 0;
}
if (isset($inputs[$student->xh . 'kszt'])) {
$student->kszt = $inputs[$student->xh . 'kszt'];
}
$total = 0;
$fails = [];
foreach ($ratios as $ratio) {
if (config('constants.score.passline') > $student->{'cj' . $ratio['id']} && config('constants.status.enable') == $ratio['allow_failed']) {
$fails[] = $student->{'cj' . $ratio['id']};
} else {
$total += $student->{'cj' . $ratio['id']} * $ratio['value'];
}
}
$student->zpcj = round(empty($fails) ? $total : min($fails));
$student->save();
}
}
return redirect()->route('score.edit', $kcxh)->withStatus('保存成绩成功');
}