當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Task::whereKcxh方法代碼示例

本文整理匯總了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);
 }
開發者ID:rxfu,項目名稱:teacher,代碼行數:19,代碼來源:TaskController.php

示例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('保存成績成功');
 }
開發者ID:rxfu,項目名稱:teacher,代碼行數:53,代碼來源:ScoreController.php


注:本文中的app\models\Task::whereKcxh方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。