123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- <?php
- namespace app\admin\controller;
- use app\common\controller\Backend;
- class UsersBox extends Backend
- {
-
-
- protected $model = null;
- public function _initialize()
- {
- parent::_initialize();
- $this->model = new \app\admin\model\UsersBox;
- $this->view->assign("statusList", $this->model->getStatusList());
- $this->view->assign("isShowList", $this->model->getIsShowList());
- }
- public function import()
- {
- parent::import();
- }
-
-
-
- public function index()
- {
-
- $this->relationSearch = true;
-
- $this->request->filter(['strip_tags', 'trim']);
- if ($this->request->isAjax()) {
-
- if ($this->request->request('keyField')) {
- return $this->selectpage();
- }
- list($where, $sort, $order, $offset, $limit) = $this->buildparams();
- $list = $this->model
- ->with(['box','users'])
- ->where(['users_box.is_del'=>0])
- ->where($where)
- ->order($sort, $order)
- ->paginate($limit);
- foreach ($list as $row) {
- $row->visible(['id','price','status','order','sales_time','create_time','is_show']);
- $row->visible(['box']);
- $row->getRelation('box')->visible(['name']);
- $row->visible(['users']);
- $row->getRelation('users')->visible(['phone']);
- }
- $result = array("total" => $list->total(), "rows" => $list->items());
- return json($result);
- }
- return $this->view->fetch();
- }
- public function del($ids = "")
- {
- $info = $this->model->where(['id'=>$ids])->find();
- if(empty($info)) return json(['code'=>0,'msg'=>'盲盒信息错误']);
- $result = $this->model->where(['id'=>$ids])->update(['is_del'=>1]);
- if($result) {
- return json(['code'=>1,'msg'=>'删除成功']);
- }
- return json(['code'=>1,'msg'=>'删除失败']);
- }
- }
|