where("title", $value); } } /** * 搜索器:试题题型 * @param $value * @param $data */ public function searchQuestionTypeAttr($query, $value, $data) { if ($value) { $query->where("question_type", $value); } } /** * 搜索器:试题创建时间 * @param $value * @param $data */ public function searchCreatedAtAttr($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([["created_at", "between", [$start, $end]]]); } else if ($start > 0 && $end == 0) { $query->where([["created_at", ">=", $start]]); } else if ($start == 0 && $end > 0) { $query->where([["created_at", "<=", $end]]); } } }