This commit is contained in:
2021-06-08 10:22:00 +08:00
parent c976279f59
commit 73823d24cb
6 changed files with 79 additions and 90 deletions

View File

@@ -53,7 +53,8 @@ function getOneArticleBYCate($categoryId, $result = '')
->whereHas('categories', function ($q) use ($categoryId) {
$q->where('id', $categoryId);
})
->latest()
->latest('sort')
->latest('created_at')
->first();
if ($info) {
@@ -87,7 +88,8 @@ function getArticlesBYCate($categoryId, $take = 8, $mark = 'one', $hasCover = fa
->whereHas('categories', function ($q) use ($categoryId) {
$q->where('id', $categoryId);
})
->orderBy('sort', $order)
->latest('sort')
->latest('created_at')
->when($hasCover, function ($q) {
$q->whereNotNull('cover');
})
@@ -104,7 +106,8 @@ function getArticlesBYCate($categoryId, $take = 8, $mark = 'one', $hasCover = fa
->when($hasCover, function ($q) {
$q->whereNotNull('cover');
})
->orderBy('sort', $order)
->latest('sort')
->latest('created_at')
->take($take)
->get();
}
@@ -179,7 +182,8 @@ function getArticlesByCateIds($take = 8, $hasCover = false)
->whereHas('categories', function ($q) use ($ids) {
$q->whereIn('id', $ids);
})
->latest()
->latest('sort')
->latest('created_at')
->when($hasCover, function ($q) {
$q->whereNotNull('cover')->orWhere('cover', '<>', '');
})
@@ -200,7 +204,8 @@ function getArticlesByCateIds($take = 8, $hasCover = false)
function getArticlesByPosition($postion)
{
$articles = Article::ofPosition($postion)
->latest()
->latest('sort')
->latest('created_at')
->take(5)
->get();