Relationmodel.php 1003 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace app\admin\controller\example;
  3. use app\common\controller\Backend;
  4. /**
  5. * 关联模型
  6. *
  7. * @icon fa fa-table
  8. * @remark 当使用到关联模型时需要重载index方法
  9. */
  10. class Relationmodel extends Backend
  11. {
  12. protected $model = null;
  13. public function _initialize()
  14. {
  15. parent::_initialize();
  16. $this->model = model('AdminLog');
  17. }
  18. /**
  19. * 查看
  20. */
  21. public function index()
  22. {
  23. $this->relationSearch = true;
  24. $this->searchFields = "admin.username,id";
  25. if ($this->request->isAjax()) {
  26. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  27. $list = $this->model
  28. ->with("admin")
  29. ->where($where)
  30. ->order($sort, $order)
  31. ->paginate($limit);
  32. $result = array("total" => $list->total(), "rows" => $list->items());
  33. return json($result);
  34. }
  35. return $this->view->fetch();
  36. }
  37. }