TaoLer/app/index/controller/Search.php

40 lines
1007 B
PHP
Raw Normal View History

<?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.
*/
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;
2022-08-02 21:13:36 +08:00
class Search extends BaseController
{
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);
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');
}
}