调整院所网站

This commit is contained in:
2022-08-19 17:30:44 +08:00
parent a1e2085bcb
commit 4751739f3c
2 changed files with 81 additions and 37 deletions

View File

@@ -10,6 +10,7 @@ use Illuminate\Support\Arr;
/** /**
* Notes: 获取一个分类 * Notes: 获取一个分类
*
* @Author: 玄尘 * @Author: 玄尘
* @Date : 2021/2/3 16:36 * @Date : 2021/2/3 16:36
* @param $categoryId * @param $categoryId
@@ -32,6 +33,7 @@ function getOneCategory($categoryId, $return = '')
/** /**
* Notes: 获取文章分类详情 * Notes: 获取文章分类详情
*
* @Author: 玄尘 * @Author: 玄尘
* @Date : 2020/9/10 13:21 * @Date : 2020/9/10 13:21
* @param $categoryId * @param $categoryId
@@ -61,6 +63,7 @@ function getOneArticleBYCate($categoryId, $result = '')
/** /**
* Notes: 获取分类下的文章 * Notes: 获取分类下的文章
*
* @Author: 玄尘 * @Author: 玄尘
* @Date : 2020/9/10 10:05 * @Date : 2020/9/10 10:05
* @param $categoryId * @param $categoryId
@@ -100,6 +103,39 @@ function getTopCate($categoryId)
return $parent; return $parent;
} }
/**
* Notes: 获取所有下级
*
* @Author: 玄尘
* @Date: 2022/8/19 17:24
* @param $array
* @param $categoryId
* @return array
*/
function getAllChild($categories, $categoryId)
{
$arr = array();
foreach ($categories as $category) {
if ($category['parent_id'] == $categoryId) {
$arr[] = $category['id'];
$arr = array_merge($arr, getAllChild($categories, $category['id']));
};
};
return $arr;
}
function getSonNode($pid = 0, $SonNode = array())
{
$SonNode[] = $pid;
foreach ($data as $k => $v) {
if ($v['source_member'] == $pid) {
$SonNode = $this->getSonNode($data, $v['member_id'], $SonNode);
}
}
unset($SonNode[0]);
return $SonNode;
}
//获取专利和论文 //获取专利和论文
function getPatent($take, $type = '') function getPatent($take, $type = '')
{ {
@@ -151,6 +187,7 @@ function getCate($id, $value = '')
/** /**
* Notes: 获取所有上级 * Notes: 获取所有上级
*
* @Author: 玄尘 * @Author: 玄尘
* @Date : 2021/2/3 13:22 * @Date : 2021/2/3 13:22
* @param $categoryId * @param $categoryId
@@ -173,6 +210,7 @@ function getAllParentCate($categoryId): array
/** /**
* Notes: 获得分类 * Notes: 获得分类
*
* @Author: 玄尘 * @Author: 玄尘
* @Date : 2021/2/3 16:38 * @Date : 2021/2/3 16:38
* @param $cate_id * @param $cate_id

View File

@@ -38,12 +38,18 @@ class CategoryController extends Controller
$template = 'category.persons'; $template = 'category.persons';
} }
if ($category->id == 74) {
$categories = Category::get();
$cate_ids = getAllChild($categories, $category->id);
} else {
$cate_ids = Category::where('parent_id', $category->id) $cate_ids = Category::where('parent_id', $category->id)
->orWhere('id', $category->id) ->orWhere('id', $category->id)
->where('status', 1) ->where('status', 1)
->whereIn('type', [Category::TYPE_ARTICLE, Category::TYPE_SHOW]) ->whereIn('type', [Category::TYPE_ARTICLE, Category::TYPE_SHOW])
->pluck('id') ->pluck('id')
->toArray(); ->toArray();
}
$articles = Article::where('status', 1) $articles = Article::where('status', 1)
->ByCategory($cate_ids) ->ByCategory($cate_ids)