49 lines
1.3 KiB
PHP
Raw Normal View History

2021-01-30 20:59:12 +08:00
<?php
2021-07-26 17:41:59 +08:00
/**
* @copyright Copyright (c) 2021 勾股工作室
2021-11-24 17:17:29 +08:00
* @license https://opensource.org/licenses/Apache-2.0
2021-07-26 17:41:59 +08:00
* @link https://www.gougucms.com
*/
2021-01-30 20:59:12 +08:00
declare (strict_types = 1);
namespace app\admin\controller;
use app\admin\BaseController;
use think\facade\Db;
use think\facade\View;
class Search extends BaseController
{
public function index()
{
if (request()->isAjax()) {
$param = get_params();
$where = array();
if (!empty($param['keywords'])) {
2021-07-26 17:41:59 +08:00
$where[] = ['title', 'like', '%' . $param['keywords'] . '%'];
}
2022-09-06 23:50:59 +08:00
$rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit'];
$content = Db::name('SearchKeywords')
->order('id desc')
->where($where)
->paginate($rows, false, ['query' => $param]);
2021-09-09 08:33:05 +08:00
return table_assign(0, '', $content);
2021-07-26 17:41:59 +08:00
} else {
return view();
2021-07-26 17:41:59 +08:00
}
2021-01-30 20:59:12 +08:00
}
//删除
public function delete()
{
$id = get_params("id");
if (Db::name('SearchKeywords')->delete($id) !== false) {
add_log('delete', $id);
2021-09-09 08:33:05 +08:00
return to_assign(0, "删除成功!");
2021-01-30 20:59:12 +08:00
} else {
2021-09-09 08:33:05 +08:00
return to_assign(1, "删除失败!");
2021-01-30 20:59:12 +08:00
}
}
}