id)->find(); // // 重新组合数组 // $num[] = $cj->yuwen; // $num[] = $cj->shuxue; // $num[] = $cj->waiyu; // // 删除空数据 // foreach ($num as $key => $value) { // if($value == null) // { // unset($num[$key]); // } // } // // 获取数组长度 // $cnt = count($num); // // 如果存在数据则计算平均分与总分 // if($cnt>0) // { // $cj->stuSum=array_sum($num); // $cj->stuAvg=$cj->stuSum/$cnt; // $cj->stuAvg = round($cj->stuAvg,1); // } // $cj->save(); // }); // } // 成绩和学科关联 public function cjSubject() { return $this->belongsTo('\app\teach\model\Subject'); } }