Customform.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace app\admin\controller\example;
  3. use app\admin\model\AdminLog;
  4. use app\common\controller\Backend;
  5. /**
  6. * 自定义表单示例
  7. *
  8. * @icon fa fa-table
  9. * @remark FastAdmin支持在控制器间跳转,点击后将切换到另外一个TAB中,无需刷新当前页面
  10. */
  11. class Customform extends Backend
  12. {
  13. protected $model = null;
  14. public function _initialize()
  15. {
  16. parent::_initialize();
  17. $this->model = model('AdminLog');
  18. }
  19. public function index()
  20. {
  21. if ($this->request->isPost()) {
  22. $this->success("提交成功", null, ['data' => json_encode($this->request->post("row/a"), JSON_UNESCAPED_UNICODE)]);
  23. }
  24. return $this->view->fetch();
  25. }
  26. public function get_title_list()
  27. {
  28. $query = $this->request->get("query");
  29. $suggestions = AdminLog::where('title', 'like', '%' . $query . '%')->limit(10)->column("title");
  30. $result = [
  31. 'query' => $query,
  32. 'suggestions' => $suggestions
  33. ];
  34. return json($result);
  35. }
  36. }