阶段性更新
This commit is contained in:
@@ -8,6 +8,14 @@ use App\Models\Talent;
|
||||
use Encore\Admin\Auth\Database\Menu;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
/**
|
||||
* Notes: 获取一个分类
|
||||
* @Author: 玄尘
|
||||
* @Date : 2021/2/3 16:36
|
||||
* @param $categoryId
|
||||
* @param string $return
|
||||
* @return \App\Models\Category
|
||||
*/
|
||||
function getOneCategory($categoryId, $return = '')
|
||||
{
|
||||
$category = Category::find($categoryId);
|
||||
@@ -114,9 +122,13 @@ function getOneAdvert($category_id, $value = '')
|
||||
}
|
||||
|
||||
//获取人才数据
|
||||
function getAllTalent()
|
||||
function getAllTalent($category_id = '')
|
||||
{
|
||||
return Talent::latest('sort')->get();
|
||||
return Talent::latest('sort')
|
||||
->when($category_id, function ($q) use ($category_id) {
|
||||
$q->where('category_id', $category_id);
|
||||
})
|
||||
->get();
|
||||
}
|
||||
|
||||
//获取一篇人才文章
|
||||
@@ -125,7 +137,7 @@ function getOneRenById($article_id)
|
||||
return Talent::find($article_id);
|
||||
}
|
||||
|
||||
//获取分类信息
|
||||
//获取菜单信息
|
||||
function getCate($id, $value = '')
|
||||
{
|
||||
$info = Menu::find($id);
|
||||
@@ -157,3 +169,28 @@ function getAllParentCate($categoryId): array
|
||||
return $res->all();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 获得分类
|
||||
* @Author: 玄尘
|
||||
* @Date : 2021/2/3 16:38
|
||||
* @param $cate_id
|
||||
* @param $
|
||||
*/
|
||||
function getArtilesByCates($cate_id, $take = 8)
|
||||
{
|
||||
$cate_ids = Category::where('parent_id', $cate_id)
|
||||
->orWhere('id', $cate_id)
|
||||
->whereIn('type', [Category::TYPE_ARTICLE, Category::TYPE_SHOW])
|
||||
->get();
|
||||
|
||||
return Article::whereIn('category_id', $cate_ids)
|
||||
->latest()
|
||||
->get();
|
||||
}
|
||||
|
||||
// 根据定位获取文章
|
||||
function getArtileByPos($position)
|
||||
{
|
||||
return Article::where('position', $position)->first();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user