From 612b69b2c05628601a5009a7e34a387d975b40a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B7=B4=E6=8E=8C?= Date: Fri, 7 Jan 2022 16:21:10 +0800 Subject: [PATCH] 0 --- app/teach/controller/BanZhuRen.php | 1 - app/teach/controller/BanjiChengji.php | 1 - app/teach/controller/FenGong.php | 3 +- app/teach/model/FenGong.php | 43 ++++++++++++++----- .../20220102124845_edit_admin_student.php | 2 +- 5 files changed, 35 insertions(+), 15 deletions(-) diff --git a/app/teach/controller/BanZhuRen.php b/app/teach/controller/BanZhuRen.php index 030f3d5d..a18dc8a4 100755 --- a/app/teach/controller/BanZhuRen.php +++ b/app/teach/controller/BanZhuRen.php @@ -1,5 +1,4 @@ '10' ,'field' => 'update_time' ,'order' => 'asc' - ,'kaoshi' => '' ,'status' => '' ,'delete_time' => '' - ,'xingzhi' => array() ,'searchval' => '' + ,'student_id' => '' ],'POST'); // 按条件查询数据 diff --git a/app/teach/model/FenGong.php b/app/teach/model/FenGong.php index c7cabe37..de9f3046 100644 --- a/app/teach/model/FenGong.php +++ b/app/teach/model/FenGong.php @@ -15,6 +15,7 @@ class FenGong extends BaseModel ,'subject_id' => 'int' ,'teacher_id' => 'int' ,'create_time' => 'int' + ,'bfdate' => 'int' ,'update_time' => 'int' ,'delete_time' => 'int' ,'beizhu' => 'varchar' @@ -26,39 +27,61 @@ class FenGong extends BaseModel { // 整理变量 $src = [ - 'status' => '' - ,'searchval' => '' + 'searchval' => '' ,'page' => 1 ,'limit' => 10 ,'field' => 'id' ,'order' => 'desc' + ,'subject_id' => '' + ,'xueqi_id' => '' ,'all' => false ]; $src = array_cover($srcfrom, $src); + $src['subject_id'] = str_to_array($src['subject_id']); + $src['xueqi_id'] = str_to_array($src['xueqi_id']); // 查询数据 $data = $this ->when(strlen($src['searchval']) > 0, function($query) use($src){ $query->where('title|jiancheng', 'like', '%' . $src['searchval'] . '%'); }) - ->with([ - 'sbjCategory' => function($query){ - $query->field('id, title'); - } - ]) + ->when(count($src['subject_id']) > 0, function($query) use($src){ + $query->where('subject_id', 'in', $src['subject_id']); + }) + ->when(count($src['xueqi_id']) > 0, function($query) use($src){ + $query->where('xueqi_id', 'in', $src['xueqi_id']); + }) ->when($src['all'] == false, function ($query) use($src) { $query ->page($src['page'], $src['limit']); }) + ->with([ + 'fgXueqi' => function ($query) { + $query->field('id, title'); + } + ,'fgSubject' => function ($query) { + $query->field('id, title, jiancheng, lieming'); + } + ]) ->order([$src['field'] => $src['order']]) ->select(); return $data; } - // 大类别关联 - public function sbjXueqi() + // 学期关联 + public function fgXueqi() { - return $this->belongsTo(\app\system\model\Category::class, 'category_id', 'id'); + return $this->belongsTo(\app\teach\model\Xueqi::class, 'xueqi_id', 'id'); } + + + // 学期关联 + public function fgSubject() + { + return $this->belongsTo(\app\teach\model\Subject::class, 'xueqi_id', 'id'); + } + + + } diff --git a/database/migrations/20220102124845_edit_admin_student.php b/database/migrations/20220102124845_edit_admin_student.php index b5fabe99..743dc5a6 100644 --- a/database/migrations/20220102124845_edit_admin_student.php +++ b/database/migrations/20220102124845_edit_admin_student.php @@ -48,7 +48,7 @@ class EditAdminStudent extends Migrator // 教师任务分工 $table = $this->table('fen_gong'); - $column = $table->hasColumn('gbfdate'); + $column = $table->hasColumn('bfdate'); if (!$column) { $table ->addColumn('bfdate','integer',['limit'=>11,'null'=>true,'comment'=>'开始日期'])