diff --git a/application/teach/controller/Xueqi.php b/application/teach/controller/Xueqi.php index a31cccca..a1252462 100644 --- a/application/teach/controller/Xueqi.php +++ b/application/teach/controller/Xueqi.php @@ -107,7 +107,7 @@ class Xueqi extends Base public function save() { // 实例化验证模型 - $validate = new \app\teach\validate\Teacher; + $validate = new \app\teach\validate\Xueqi; // 获取表单数据 @@ -121,7 +121,7 @@ class Xueqi extends Base // 如果验证不通过则停止保存 if(!$result){ - return json(['msg'=>$msg,'val'=>0]);; + return json(['msg'=>$msg,'val'=>0]); } // 保存数据 @@ -164,7 +164,7 @@ class Xueqi extends Base // 更新学期信息 public function update($id) { - $validate = new \app\teach\validate\Teacher; + $validate = new \app\teach\validate\Xueqi; // 获取表单数据 $list = request()->only(['title','xuenian','category','bfdate','enddate'],'put'); @@ -180,8 +180,8 @@ class Xueqi extends Base // 更新数据 - $teacher = new Teacher(); - $data = $teacher->save($list,['id'=>$id]); + $xq = new XQ(); + $data = $xq->save($list,['id'=>$id]); // $data = XQ::where('id',$id)->update($list); // 根据更新结果设置返回提示信息 diff --git a/application/teach/model/Xueqi.php b/application/teach/model/Xueqi.php index e7bbafec..c387f982 100644 --- a/application/teach/model/Xueqi.php +++ b/application/teach/model/Xueqi.php @@ -30,4 +30,12 @@ class Xueqi extends Base { return date('Y-m-d',$value); } + + // 分类获取器 + public function getcategoryAttr($value) + { + return db('category') + ->where('id',$value) + ->value('title'); + } } diff --git a/application/teach/validate/Xueqi.php b/application/teach/validate/Xueqi.php index 99132f62..fa750332 100644 --- a/application/teach/validate/Xueqi.php +++ b/application/teach/validate/Xueqi.php @@ -13,11 +13,11 @@ class Xueqi extends Validate * @var array */ protected $rule = [ - 'title|标题' => 'required|length:2,25', - 'xuenian|学年' => 'required|length:1,15', - 'category|分类' => 'required|number', - 'bfdate|时间' => 'required|date', - 'enddate|时间' => 'required|date', + 'title|标题' => 'require|length:2,25', + 'xuenian|学年' => 'require|length:1,15', + 'category|分类' => 'require|number', + 'bfdate|时间' => 'require|date', + 'enddate|时间' => 'require|date', ]; /** diff --git a/application/teach/view/xueqi/create.html b/application/teach/view/xueqi/create.html index dcd86fe3..cc2c6153 100644 --- a/application/teach/view/xueqi/create.html +++ b/application/teach/view/xueqi/create.html @@ -18,7 +18,7 @@