12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- <?php
- namespace app\admin\controller;
- use app\common\controller\Backend;
- class Package extends Backend
- {
-
- protected $model = null;
- public function _initialize()
- {
- parent::_initialize();
- $this->model = new \app\admin\model\Package;
- $this->view->assign("statusList", $this->model->getStatusList());
- }
-
-
- 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();
-
- $where_op = [];
- if($this->auth->company_id){
- $where_op['package.company_id'] = $this->auth->company_id;
- }
- $list = $this->model
- ->with(['company','servicetype'])
- ->where($where)
- ->where($where_op)
- ->order($sort, $order)
- ->paginate($limit);
- foreach ($list as $row) {
-
- $row->getRelation('company')->visible(['name']);
- $row->getRelation('servicetype')->visible(['title']);
- }
- $result = array("total" => $list->total(), "rows" => $list->items());
- return json($result);
- }
- return $this->view->fetch();
- }
- }
|