调整院所网站
This commit is contained in:
@@ -10,10 +10,11 @@ use Illuminate\Support\Arr;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Notes: 获取一个分类
|
* Notes: 获取一个分类
|
||||||
|
*
|
||||||
* @Author: 玄尘
|
* @Author: 玄尘
|
||||||
* @Date : 2021/2/3 16:36
|
* @Date : 2021/2/3 16:36
|
||||||
* @param $categoryId
|
* @param $categoryId
|
||||||
* @param string $return
|
* @param string $return
|
||||||
* @return \App\Models\Category
|
* @return \App\Models\Category
|
||||||
*/
|
*/
|
||||||
function getOneCategory($categoryId, $return = '')
|
function getOneCategory($categoryId, $return = '')
|
||||||
@@ -32,19 +33,20 @@ function getOneCategory($categoryId, $return = '')
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Notes: 获取文章分类详情
|
* Notes: 获取文章分类详情
|
||||||
|
*
|
||||||
* @Author: 玄尘
|
* @Author: 玄尘
|
||||||
* @Date : 2020/9/10 13:21
|
* @Date : 2020/9/10 13:21
|
||||||
* @param $categoryId
|
* @param $categoryId
|
||||||
* @param string $result
|
* @param string $result
|
||||||
* @return \App\Models\Article
|
* @return \App\Models\Article
|
||||||
*/
|
*/
|
||||||
function getOneArticleBYCate($categoryId, $result = '')
|
function getOneArticleBYCate($categoryId, $result = '')
|
||||||
{
|
{
|
||||||
$info = Article::where('status', 1)
|
$info = Article::where('status', 1)
|
||||||
->ByCategory($categoryId)
|
->ByCategory($categoryId)
|
||||||
->latest('sort')
|
->latest('sort')
|
||||||
->latest()
|
->latest()
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
if ($info) {
|
if ($info) {
|
||||||
if ($result) {
|
if ($result) {
|
||||||
@@ -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
|
||||||
@@ -70,11 +73,11 @@ function getOneArticleBYCate($categoryId, $result = '')
|
|||||||
function getArticlesBYCate($categoryId, $take)
|
function getArticlesBYCate($categoryId, $take)
|
||||||
{
|
{
|
||||||
$articles = Article::where('status', 1)
|
$articles = Article::where('status', 1)
|
||||||
->ByCategory($categoryId)
|
->ByCategory($categoryId)
|
||||||
->latest('sort')
|
->latest('sort')
|
||||||
->latest()
|
->latest()
|
||||||
->take($take)
|
->take($take)
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
return $articles;
|
return $articles;
|
||||||
}
|
}
|
||||||
@@ -83,9 +86,9 @@ function getArticlesBYCate($categoryId, $take)
|
|||||||
function getCateChild($categoryId)
|
function getCateChild($categoryId)
|
||||||
{
|
{
|
||||||
return Category::where('status', 1)
|
return Category::where('status', 1)
|
||||||
->where('parent_id', $categoryId)
|
->where('parent_id', $categoryId)
|
||||||
->orderBy('order', 'asc')
|
->orderBy('order', 'asc')
|
||||||
->get();
|
->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取顶级分类
|
//获取顶级分类
|
||||||
@@ -100,14 +103,47 @@ 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 = '')
|
||||||
{
|
{
|
||||||
return Patent::where('status', 1)
|
return Patent::where('status', 1)
|
||||||
->when($type, function ($q) use ($type) {
|
->when($type, function ($q) use ($type) {
|
||||||
$q->where('type', $type);
|
$q->where('type', $type);
|
||||||
})
|
})
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,10 +162,10 @@ function getOneAdvert($category_id, $value = '')
|
|||||||
function getAllTalent($category_id = '')
|
function getAllTalent($category_id = '')
|
||||||
{
|
{
|
||||||
return Talent::latest('sort')
|
return Talent::latest('sort')
|
||||||
->when($category_id, function ($q) use ($category_id) {
|
->when($category_id, function ($q) use ($category_id) {
|
||||||
$q->where('category_id', $category_id);
|
$q->where('category_id', $category_id);
|
||||||
})
|
})
|
||||||
->get();
|
->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取一篇人才文章
|
//获取一篇人才文章
|
||||||
@@ -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
|
||||||
@@ -181,17 +219,17 @@ function getAllParentCate($categoryId): array
|
|||||||
function getArtilesByCates($cate_id, $take = 8)
|
function getArtilesByCates($cate_id, $take = 8)
|
||||||
{
|
{
|
||||||
$cate_ids = Category::where('parent_id', $cate_id)
|
$cate_ids = Category::where('parent_id', $cate_id)
|
||||||
->orWhere('id', $cate_id)
|
->orWhere('id', $cate_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();
|
||||||
|
|
||||||
return Article::where('status', 1)
|
return Article::where('status', 1)
|
||||||
->latest()
|
->latest()
|
||||||
->ByCategory($cate_ids)
|
->ByCategory($cate_ids)
|
||||||
->take($take)
|
->take($take)
|
||||||
->get();
|
->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 根据定位获取文章
|
// 根据定位获取文章
|
||||||
|
|||||||
@@ -38,12 +38,18 @@ class CategoryController extends Controller
|
|||||||
$template = 'category.persons';
|
$template = 'category.persons';
|
||||||
}
|
}
|
||||||
|
|
||||||
$cate_ids = Category::where('parent_id', $category->id)
|
if ($category->id == 74) {
|
||||||
->orWhere('id', $category->id)
|
$categories = Category::get();
|
||||||
->where('status', 1)
|
$cate_ids = getAllChild($categories, $category->id);
|
||||||
->whereIn('type', [Category::TYPE_ARTICLE, Category::TYPE_SHOW])
|
} else {
|
||||||
->pluck('id')
|
$cate_ids = Category::where('parent_id', $category->id)
|
||||||
->toArray();
|
->orWhere('id', $category->id)
|
||||||
|
->where('status', 1)
|
||||||
|
->whereIn('type', [Category::TYPE_ARTICLE, Category::TYPE_SHOW])
|
||||||
|
->pluck('id')
|
||||||
|
->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$articles = Article::where('status', 1)
|
$articles = Article::where('status', 1)
|
||||||
->ByCategory($cate_ids)
|
->ByCategory($cate_ids)
|
||||||
|
|||||||
Reference in New Issue
Block a user