调整院所网站
This commit is contained in:
@@ -10,6 +10,7 @@ use Illuminate\Support\Arr;
|
||||
|
||||
/**
|
||||
* Notes: 获取一个分类
|
||||
*
|
||||
* @Author: 玄尘
|
||||
* @Date : 2021/2/3 16:36
|
||||
* @param $categoryId
|
||||
@@ -32,6 +33,7 @@ function getOneCategory($categoryId, $return = '')
|
||||
|
||||
/**
|
||||
* Notes: 获取文章分类详情
|
||||
*
|
||||
* @Author: 玄尘
|
||||
* @Date : 2020/9/10 13:21
|
||||
* @param $categoryId
|
||||
@@ -61,6 +63,7 @@ function getOneArticleBYCate($categoryId, $result = '')
|
||||
|
||||
/**
|
||||
* Notes: 获取分类下的文章
|
||||
*
|
||||
* @Author: 玄尘
|
||||
* @Date : 2020/9/10 10:05
|
||||
* @param $categoryId
|
||||
@@ -100,6 +103,39 @@ function getTopCate($categoryId)
|
||||
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 = '')
|
||||
{
|
||||
@@ -151,6 +187,7 @@ function getCate($id, $value = '')
|
||||
|
||||
/**
|
||||
* Notes: 获取所有上级
|
||||
*
|
||||
* @Author: 玄尘
|
||||
* @Date : 2021/2/3 13:22
|
||||
* @param $categoryId
|
||||
@@ -173,6 +210,7 @@ function getAllParentCate($categoryId): array
|
||||
|
||||
/**
|
||||
* Notes: 获得分类
|
||||
*
|
||||
* @Author: 玄尘
|
||||
* @Date : 2021/2/3 16:38
|
||||
* @param $cate_id
|
||||
|
||||
@@ -38,12 +38,18 @@ class CategoryController extends Controller
|
||||
$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)
|
||||
->orWhere('id', $category->id)
|
||||
->where('status', 1)
|
||||
->whereIn('type', [Category::TYPE_ARTICLE, Category::TYPE_SHOW])
|
||||
->pluck('id')
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
$articles = Article::where('status', 1)
|
||||
->ByCategory($cate_ids)
|
||||
|
||||
Reference in New Issue
Block a user