where("id", $value); } } /** * 搜索器:作业管理学员 * @param $value * @param $data */ public function searchStudentIdAttr($query, $value, $data) { if ($value) { $query->where("student_id", $value); } } /** * 搜索器:作业管理班级 * @param $value * @param $data */ public function searchClassIdAttr($query, $value, $data) { if ($value) { $query->where("class_id", $value); } } /** * 搜索器:作业管理批改教练 * @param $value * @param $data */ public function searchStaffIdAttr($query, $value, $data) { if ($value) { $query->where("staff_id", $value); } } /** * 搜索器:作业管理作业类型 * @param $value * @param $data */ public function searchContentTypeAttr($query, $value, $data) { if ($value) { $query->where("content_type", $value); } } /** * 搜索器:作业管理提交时间 * @param $value * @param $data */ public function searchSubmitTimeAttr($query, $value, $data) { $start = empty($value[0]) ? 0 : strtotime($value[0]); $end = empty($value[1]) ? 0 : strtotime($value[1]); if ($start > 0 && $end > 0) { $query->where([["submit_time", "between", [$start, $end]]]); } else if ($start > 0 && $end == 0) { $query->where([["submit_time", ">=", $start]]); } else if ($start == 0 && $end > 0) { $query->where([["submit_time", "<=", $end]]); } } /** * 搜索器:作业管理评分 * @param $value * @param $data */ public function searchScoreAttr($query, $value, $data) { $start = empty($value[0]) ? 0 : $value[0]; $end = empty($value[1]) ? 0 : $value[1]; if ($start > 0 && $end > 0) { $query->where([["score", "between", [$start, $end]]]); } else if ($start > 0 && $end == 0) { $query->where([["score", ">=", $start]]); } else if ($start == 0 && $end > 0) { $query->where([["score", "<=", $end]]); } } /** * 搜索器:作业管理状态 * @param $value * @param $data */ public function searchStatusAttr($query, $value, $data) { if ($value) { $query->where("status", $value); } } /** * 搜索器:作业管理添加时间 * @param $value * @param $data */ public function searchCreateTimeAttr($query, $value, $data) { $start = empty($value[0]) ? 0 : strtotime($value[0]); $end = empty($value[1]) ? 0 : strtotime($value[1]); if ($start > 0 && $end > 0) { $query->where([["create_time", "between", [$start, $end]]]); } else if ($start > 0 && $end == 0) { $query->where([["create_time", ">=", $start]]); } else if ($start == 0 && $end > 0) { $query->where([["create_time", "<=", $end]]); } } public function students(){ return $this->hasOne(Students::class, 'id', 'student_id')->joinType('left')->withField('name,id')->bind(['student_id_name'=>'name']); } public function classes(){ return $this->hasOne(Classes::class, 'id', 'class_id')->joinType('left')->withField('name,id')->bind(['class_id_name'=>'name']); } public function staff(){ return $this->hasOne(Staff::class, 'id', 'staff_id')->joinType('left')->withField('name,id')->bind(['staff_id_name'=>'name']); } }