123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- <?php
- namespace app\admin\controller\gift;
- use app\common\controller\Backend;
- class Gift extends Backend
- {
-
-
- protected $model = null;
- public function _initialize()
- {
- parent::_initialize();
- $this->model = new \app\admin\model\gift\Gift;
- $this->view->assign("isBigList", $this->model->getIsBigList());
- $this->view->assign("typeList", $this->model->getTypeList());
- $this->view->assign("boxtypeList", $this->model->getBoxtypeList());
- $this->view->assign("complexList", $this->model->getComplexList());
- $this->view->assign("timelimitList", $this->model->getTimelimitList());
- }
- 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();
- $appendWhere = [];
- if ($this->request->param('id')) {
- $appendWhere['gift.id'] = $this->request->param('id');
- }
- $list = $this->model
- ->with(['gifttype'])
- ->where($where)
- ->where($appendWhere)
- ->order($sort, $order)
- ->paginate($limit);
- foreach ($list as $row) {
- $row->getRelation('gifttype')->visible(['name']);
- }
- $result = array("total" => $list->total(), "rows" => $list->items());
- return json($result);
- }
- return $this->view->fetch();
- }
-
- public function detail()
- {
- $id = $this->request->param('id',0);
- $data = [];
- if (!empty($id)) {
- $where['id'] = $id;
- $data = $this->model->where($where)->find();
- }
- $result = [
- 'status' => 1,
- 'msg' => '获取成功',
- 'data' => $data,
- ];
- return json_encode($result);
- }
- }
|