Buying.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace app\admin\controller\product;
  3. use app\common\controller\Backend;
  4. /**
  5. * 寄售求购
  6. *
  7. * @icon fa fa-circle-o
  8. */
  9. class Buying extends Backend
  10. {
  11. /**
  12. * Buying模型对象
  13. * @var \app\admin\model\product\Buying
  14. */
  15. protected $model = null;
  16. public function _initialize()
  17. {
  18. parent::_initialize();
  19. $this->model = new \app\common\model\ProductBuying();
  20. }
  21. public function index()
  22. {
  23. //设置过滤方法
  24. $this->request->filter(['strip_tags', 'trim']);
  25. if (false === $this->request->isAjax()) {
  26. return $this->view->fetch();
  27. }
  28. //如果发送的来源是 Selectpage,则转发到 Selectpage
  29. if ($this->request->request('keyField')) {
  30. return $this->selectpage();
  31. }
  32. [$where, $sort, $order, $offset, $limit] = $this->buildparams();
  33. $ids = $this->request->param('ids');
  34. $list = $this->model->with('users,productlists')
  35. ->where($where)
  36. //->where('synthesis_id', '=', $ids)
  37. ->order($sort, $order)
  38. ->paginate($limit);
  39. $result = ['total' => $list->total(), 'rows' => $list->items()];
  40. return json($result);
  41. }
  42. }