文章分类由1变多

This commit is contained in:
2021-04-02 09:30:56 +08:00
parent e2699b7e04
commit 977dd11c7d
19 changed files with 177 additions and 287 deletions

View File

@@ -13,7 +13,7 @@ use Illuminate\Support\Arr;
* @Author: 玄尘
* @Date : 2021/2/3 16:36
* @param $categoryId
* @param string $return
* @param string $return
* @return \App\Models\Category
*/
function getOneCategory($categoryId, $return = '')
@@ -35,12 +35,13 @@ function getOneCategory($categoryId, $return = '')
* @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('category_id', $categoryId)
$info = Article::where('status', 1)
->ByCategory($categoryId)
->latest('sort')
->latest()
->first();
@@ -68,8 +69,8 @@ function getOneArticleBYCate($categoryId, $result = '')
*/
function getArticlesBYCate($categoryId, $take)
{
$articles = Article::where('category_id', $categoryId)
->where('status', 1)
$articles = Article::where('status', 1)
->ByCategory($categoryId)
->latest('sort')
->latest()
->take($take)
@@ -186,8 +187,9 @@ function getArtilesByCates($cate_id, $take = 8)
->pluck('id')
->toArray();
return Article::whereIn('category_id', $cate_ids)
return Article::where('status', 1)
->latest()
->ByCategory($cate_ids)
->take($take)
->get();
}