This commit is contained in:
李志强 2025-06-06 11:25:38 +08:00
parent eca0f18501
commit 9097c77c41

View File

@ -13,7 +13,7 @@ class SearchController extends BaseController
public function index() public function index()
{ {
$keyword = input('keyword', ''); $keyword = input('keyword', '');
$type = input('type', 'article'); // 搜索类型article-文章resource-资源 $type = input('type', 'articles'); // 搜索类型article-文章resource-资源
$page = input('page', 1); $page = input('page', 1);
$limit = input('limit', 10); $limit = input('limit', 10);
@ -22,7 +22,7 @@ class SearchController extends BaseController
} }
// 根据类型选择对应的表和分类表 // 根据类型选择对应的表和分类表
if ($type == 'article') { if ($type == 'articles') {
$model = new Articles(); $model = new Articles();
$categoryModel = new ArticlesCategory(); $categoryModel = new ArticlesCategory();
$detailUrl = '/index/articles/detail'; $detailUrl = '/index/articles/detail';
@ -55,7 +55,7 @@ class SearchController extends BaseController
// 获取分类名称和图片 // 获取分类名称和图片
foreach ($items as &$item) { foreach ($items as &$item) {
if ($type == 'article') { if ($type == 'articles') {
$category = $categoryModel->where('id', $item['cate']) $category = $categoryModel->where('id', $item['cate'])
->field('id, name, image') ->field('id, name, image')
->find(); ->find();