isAuth = false; parent::__construct(); $this->selectField = [ 'id', 'user_id', 'title', 'cover', 'category_id', 'is_sold', 'description', 'module_image', 'flowchart', 'content', 'video_url', 'author_id', 'price', 'preferential_price', 'front', 'service', 'deploy', 'status', 'created_at', 'updated_at', 'deleted_at', ]; $this->model = ProjectModel::class; } /** * 获取精选项目 * @return array * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ public function list(): array { $this->where[] = [ 'is_selected', '=', 1 ]; $this->where[] = [ 'status', '=', 1 ]; $this->with = [ 'frameworks:id,name', 'labels:id,name', 'category:id,name', ]; return $this->getPageList(); } /** * 获取项目列表 * @return array * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ public function projectList(): array { $this->queryField = [ 'title' => 'like' ]; $this->where[] = [ 'status', '=', 1 ]; $this->with = [ 'frameworks:id,name', 'labels:id,name', 'category:id,name', ]; return $this->getPageList(); } /** * 获取轮播图 * @return array * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ public function carousel(): array { $this->where[] = [ 'is_carousel', '=', 1 ]; $this->where[] = [ 'status', '=', 1 ]; $this->with = [ 'frameworks:id,name', 'labels:id,name', 'category:id,name', ]; return $this->getPageList(); } public function detail($id) { $this->with = [ 'frameworks:id,name', 'labels:id,name', 'category:id,name', 'screenshots:id,url,project_id', 'features:id,project_id,name', 'author:id,nick_name,avatar,email' ]; $result = $this->getDetail($id); if (!empty($this->userId)) { $result['is_collection'] = CollectionModel::where('project_id', $id)->where('user_id', $this->userId)->exists(); } else { $result['is_collection'] = false; } return $result; } }