where("staff_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 searchDateTimeAttr($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([["date_time", "between", [$start, $end]]]); } else if ($start > 0 && $end == 0) { $query->where([["date_time", ">=", $start]]); } else if ($start == 0 && $end > 0) { $query->where([["date_time", "<=", $end]]); } } /** * 搜索器:排班管理任务描述 * @param $value * @param $data */ public function searchTaskAttr($query, $value, $data) { if ($value) { $query->where("task", $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 staff(){ return $this->hasOne(Staff::class, 'id', 'staff_id')->joinType('left')->withField('name,id')->bind(['staff_id_name'=>'name']); } public function classes(){ return $this->hasOne(Classes::class, 'id', 'class_id')->joinType('left')->withField('name,id')->bind(['class_id_name'=>'name']); } }