interestCircleArticle = $interestCircleArticle; } /** * 内容列表 */ public function lists($request) { $perPage = isset($request['per_page']) ? $request['per_page'] : 20; $where = []; if (isset($request['uid'])) { $where[] = ['uid', $request['uid']]; } $articleModel = $this->interestCircleArticle; return $articleModel ->join('post', 'post.id', '=', 'post_id') ->join('post_data', 'post_data.post_id', '=', 'post.id') ->with('data') ->select('post.*') ->where($where) ->where(function ($query) use ($request) { if (isset($request['content'])) { $query->where('title', 'like', "%{$request['content']}%") ->orWhere('content', 'like', "%{$request['content']}%"); } }) ->where(function ($query) use ($request) { if (isset($request['created_at'])) { $time = explode('_', $request['created_at']); $query->whereBetween('post.created_at', $time); } }) ->orderBy('is_recommend', 'desc') ->paginate($perPage); } }