阶段性更新
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Advert;
|
||||
use App\Models\Category;
|
||||
use App\Models\Article;
|
||||
use App\Models\Video;
|
||||
|
||||
function getOneCategory($categoryId, $return = '')
|
||||
{
|
||||
@@ -21,8 +23,8 @@ function getOneCategory($categoryId, $return = '')
|
||||
* Notes: 获取文章分类详情
|
||||
* @Author: 玄尘
|
||||
* @Date : 2020/9/10 13:21
|
||||
* @param $categoryId
|
||||
* @param string $result
|
||||
* @param $categoryId
|
||||
* @param string $result
|
||||
* @return \App\Models\Article
|
||||
*/
|
||||
function getOneArticleBYCate($categoryId, $result = '')
|
||||
@@ -48,8 +50,9 @@ function getOneArticleBYCate($categoryId, $result = '')
|
||||
* Notes: 获取分类下的文章
|
||||
* @Author: 玄尘
|
||||
* @Date : 2020/9/10 10:05
|
||||
* @param $categoryId
|
||||
* @param $take
|
||||
* @param $categoryId
|
||||
* @param int $take
|
||||
* @param string $mark
|
||||
* @return \App\Models\Article
|
||||
*/
|
||||
function getArticlesBYCate($categoryId, $take = 8, $mark = 'one')
|
||||
@@ -63,7 +66,7 @@ function getArticlesBYCate($categoryId, $take = 8, $mark = 'one')
|
||||
->get();
|
||||
} else {
|
||||
$cate = Category::find($categoryId);
|
||||
$ids = $cate->getAllChildrenId();
|
||||
$ids = $cate ? $cate->getAllChildrenId() : [];
|
||||
|
||||
$articles = Article::where('status', 1)
|
||||
->ByCategory($ids)
|
||||
@@ -97,3 +100,54 @@ function getTopCate($categoryId)
|
||||
return $parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 根据分类获取一张图片
|
||||
* @Author: 玄尘
|
||||
* @Date : 2021/10/8 13:53
|
||||
* @param $categoryId
|
||||
* @param string $result
|
||||
* @return string
|
||||
*/
|
||||
function getOneAdvertByCate($categoryId, $result = '')
|
||||
{
|
||||
$info = Advert::where('category_id', $categoryId)
|
||||
->latest('sort')
|
||||
->latest()
|
||||
->first();
|
||||
|
||||
if ($info) {
|
||||
if ($result) {
|
||||
return $info->{$result};
|
||||
}
|
||||
|
||||
return $info;
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
function getVideoByCate($categoryId, $result = '')
|
||||
{
|
||||
$video = Video::where('category_id', $categoryId)
|
||||
->latest()
|
||||
->first();
|
||||
|
||||
if ($video) {
|
||||
if ($result) {
|
||||
return $video->{$result};
|
||||
}
|
||||
|
||||
return $video;
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
function getVideosByCate($categoryId, $take = '8')
|
||||
{
|
||||
return Video::where('category_id', $categoryId)
|
||||
->latest()
|
||||
->take($take)
|
||||
->get();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user