调整院所网站

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,10 +10,11 @@ use Illuminate\Support\Arr;
/**
* Notes: 获取一个分类
*
* @Author: 玄尘
* @Date : 2021/2/3 16:36
* @param $categoryId
* @param string $return
* @param string $return
* @return \App\Models\Category
*/
function getOneCategory($categoryId, $return = '')
@@ -32,19 +33,20 @@ function getOneCategory($categoryId, $return = '')
/**
* Notes: 获取文章分类详情
*
* @Author: 玄尘
* @Date : 2020/9/10 13:21
* @param $categoryId
* @param string $result
* @param string $result
* @return \App\Models\Article
*/
function getOneArticleBYCate($categoryId, $result = '')
{
$info = Article::where('status', 1)
->ByCategory($categoryId)
->latest('sort')
->latest()
->first();
->ByCategory($categoryId)
->latest('sort')
->latest()
->first();
if ($info) {
if ($result) {
@@ -61,6 +63,7 @@ function getOneArticleBYCate($categoryId, $result = '')
/**
* Notes: 获取分类下的文章
*
* @Author: 玄尘
* @Date : 2020/9/10 10:05
* @param $categoryId
@@ -70,11 +73,11 @@ function getOneArticleBYCate($categoryId, $result = '')
function getArticlesBYCate($categoryId, $take)
{
$articles = Article::where('status', 1)
->ByCategory($categoryId)
->latest('sort')
->latest()
->take($take)
->get();
->ByCategory($categoryId)
->latest('sort')
->latest()
->take($take)
->get();
return $articles;
}
@@ -83,9 +86,9 @@ function getArticlesBYCate($categoryId, $take)
function getCateChild($categoryId)
{
return Category::where('status', 1)
->where('parent_id', $categoryId)
->orderBy('order', 'asc')
->get();
->where('parent_id', $categoryId)
->orderBy('order', 'asc')
->get();
}
//获取顶级分类
@@ -100,14 +103,47 @@ 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 = '')
{
return Patent::where('status', 1)
->when($type, function ($q) use ($type) {
$q->where('type', $type);
})
->get();
->when($type, function ($q) use ($type) {
$q->where('type', $type);
})
->get();
}
@@ -126,10 +162,10 @@ function getOneAdvert($category_id, $value = '')
function getAllTalent($category_id = '')
{
return Talent::latest('sort')
->when($category_id, function ($q) use ($category_id) {
$q->where('category_id', $category_id);
})
->get();
->when($category_id, function ($q) use ($category_id) {
$q->where('category_id', $category_id);
})
->get();
}
//获取一篇人才文章
@@ -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
@@ -181,17 +219,17 @@ function getAllParentCate($categoryId): array
function getArtilesByCates($cate_id, $take = 8)
{
$cate_ids = Category::where('parent_id', $cate_id)
->orWhere('id', $cate_id)
->where('status', 1)
->whereIn('type', [Category::TYPE_ARTICLE, Category::TYPE_SHOW])
->pluck('id')
->toArray();
->orWhere('id', $cate_id)
->where('status', 1)
->whereIn('type', [Category::TYPE_ARTICLE, Category::TYPE_SHOW])
->pluck('id')
->toArray();
return Article::where('status', 1)
->latest()
->ByCategory($cate_ids)
->take($take)
->get();
->latest()
->ByCategory($cate_ids)
->take($take)
->get();
}
// 根据定位获取文章