2020-11-27 16:25:08 +08:00
|
|
|
<?php
|
2022-08-02 21:13:36 +08:00
|
|
|
/*
|
|
|
|
* @Author: TaoLer <317927823@qq.com>
|
|
|
|
* @Date: 2021-12-06 16:04:50
|
|
|
|
* @LastEditTime: 2022-07-20 13:21:54
|
|
|
|
* @LastEditors: TaoLer
|
|
|
|
* @Description: 优化版
|
|
|
|
* @FilePath: \TaoLer\app\index\controller\Search.php
|
|
|
|
* Copyright (c) 2020~2022 https://www.aieok.com All rights reserved.
|
|
|
|
*/
|
2020-11-27 16:25:08 +08:00
|
|
|
|
|
|
|
namespace app\index\controller;
|
|
|
|
|
2022-08-02 21:13:36 +08:00
|
|
|
use app\common\controller\BaseController;
|
|
|
|
use think\facade\View;
|
|
|
|
use think\facade\Request;
|
|
|
|
use app\facade\Article;
|
2020-11-27 16:25:08 +08:00
|
|
|
|
2022-08-02 21:13:36 +08:00
|
|
|
class Search extends BaseController
|
2020-11-27 16:25:08 +08:00
|
|
|
{
|
2022-08-02 21:13:36 +08:00
|
|
|
//搜索功能
|
|
|
|
public function getSearch()
|
|
|
|
{
|
|
|
|
$ser = Request::only(['keywords']);
|
|
|
|
$artList = Article::getSearchKeyWord($ser['keywords']);
|
|
|
|
$counts = $artList->count();
|
|
|
|
// 查询热议
|
|
|
|
$artHot = Article::getArtHot(10);
|
2020-11-27 16:25:08 +08:00
|
|
|
|
2022-08-02 21:13:36 +08:00
|
|
|
$searchs = [
|
|
|
|
'artList' => $artList,
|
|
|
|
'keywords' => $ser['keywords'],
|
|
|
|
'counts' => $counts,
|
|
|
|
'artHot'=>$artHot,
|
|
|
|
'jspage'=>''
|
|
|
|
];
|
|
|
|
View::assign($searchs);
|
|
|
|
return View::fetch('search');
|
|
|
|
}
|
2020-11-27 16:25:08 +08:00
|
|
|
}
|