阶段更新
This commit is contained in:
@@ -52,39 +52,36 @@ function getOneArticleBYCate($categoryId, $result = '')
|
||||
* @Date : 2020/9/10 10:05
|
||||
* @param $categoryId
|
||||
* @param int $take
|
||||
* @param string $mark
|
||||
* @param int $recommen
|
||||
* @return \App\Models\Article
|
||||
*/
|
||||
function getArticlesBYCate($categoryId, $take = 8, $mark = 'one')
|
||||
function getArticlesBYCate($categoryId, $take = 8, $recommen = 0)
|
||||
{
|
||||
if ($mark == 'one') {
|
||||
$articles = Article::where('status', 1)
|
||||
->ByCategory($categoryId)
|
||||
->latest('sort')
|
||||
->latest()
|
||||
->take($take)
|
||||
->get();
|
||||
} else {
|
||||
$cate = Category::find($categoryId);
|
||||
$ids = $cate ? $cate->getAllChildrenId() : [];
|
||||
$cate = Category::find($categoryId);
|
||||
$ids = $cate ? $cate->getAllChildrenId() : [];
|
||||
|
||||
$articles = Article::where('status', 1)
|
||||
->ByCategory($ids)
|
||||
->latest('sort')
|
||||
->latest()
|
||||
->take($take)
|
||||
->get();
|
||||
}
|
||||
$articles = Article::where('status', 1)
|
||||
->ByCategory([$categoryId])
|
||||
->latest('sort')
|
||||
->latest()
|
||||
->when($recommen, function ($q) use ($recommen) {
|
||||
$q->where('recommen', 1);
|
||||
})
|
||||
->take($take)
|
||||
->get();
|
||||
|
||||
return $articles;
|
||||
}
|
||||
|
||||
//获取子分类
|
||||
function getCateChild($categoryId)
|
||||
function getCateChild($categoryId, $take = '')
|
||||
{
|
||||
return Category::where('status', 1)
|
||||
->where('parent_id', $categoryId)
|
||||
->orderBy('order', 'desc')
|
||||
->when($take, function ($q) use ($take) {
|
||||
$q->take($take);
|
||||
})
|
||||
->get();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user