Search.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2021 勾股工作室
  4. * @license https://opensource.org/licenses/Apache-2.0
  5. * @link https://www.gougucms.com
  6. */
  7. declare (strict_types = 1);
  8. namespace app\admin\controller;
  9. use app\admin\BaseController;
  10. use think\facade\Db;
  11. use think\facade\View;
  12. class Search extends BaseController
  13. {
  14. public function index()
  15. {
  16. if (request()->isAjax()) {
  17. $param = get_params();
  18. $where = array();
  19. if (!empty($param['keywords'])) {
  20. $where[] = ['title', 'like', '%' . $param['keywords'] . '%'];
  21. }
  22. $rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit'];
  23. $content = Db::name('SearchKeywords')
  24. ->order('id desc')
  25. ->where($where)
  26. ->paginate($rows, false, ['query' => $param]);
  27. return table_assign(0, '', $content);
  28. } else {
  29. return view();
  30. }
  31. }
  32. //删除
  33. public function delete()
  34. {
  35. $id = get_params("id");
  36. if (Db::name('SearchKeywords')->delete($id) !== false) {
  37. add_log('delete', $id);
  38. return to_assign(0, "删除成功!");
  39. } else {
  40. return to_assign(1, "删除失败!");
  41. }
  42. }
  43. }