where("title", "like", "%".$value."%"); } } /** * 搜索器:文章管理文章分类 * @param $value * @param $data */ public function searchCategoryAttr($query, $value, $data) { if ($value) { $query->where("category", $value); } } /** * 搜索器:文章管理发布人 * @param $value * @param $data */ public function searchPublisherIdAttr($query, $value, $data) { if ($value) { $query->where("publisher_id", $value); } } /** * 搜索器:文章管理状态 * @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]]); } } /** * 搜索器:文章管理更新时间 * @param $value * @param $data */ public function searchUpdateTimeAttr($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([["update_time", "between", [$start, $end]]]); } else if ($start > 0 && $end == 0) { $query->where([["update_time", ">=", $start]]); } else if ($start == 0 && $end > 0) { $query->where([["update_time", "<=", $end]]); } } public function sysUser(){ return $this->hasOne(SysUser::class, 'uid', 'publisher_id')->joinType('left')->withField('username,uid')->bind(['publisher_id_name'=>'username']); } }