<?php
namespace app\admin\controller\user;
use app\common\controller\Backend;
class User extends Backend
{
protected $relationSearch = true;
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = model('User');
}
public function index()
{
$this->request->filter(['strip_tags']);
if ($this->request->isAjax())
{
if ($this->request->request('keyField'))
{
return $this->selectpage();
}
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$total = $this->model
->with('group')
->where($where)
->order($sort, $order)
->count();
$list = $this->model
->with('group')
->where($where)
->order($sort, $order)
->limit($offset, $limit)
->select();
foreach ($list as $k => $v)
{
$v->hidden(['password', 'salt']);
}
$result = array("total" => $total, "rows" => $list);
return json($result);
}
return $this->view->fetch();
}
public function edit($ids = NULL)
{
$row = $this->model->get($ids);
if (!$row)
$this->error(__('No Results were found'));
$this->view->assign('groupList', build_select('row[group_id]', \app\admin\model\UserGroup::column('id,name'), $row['group_id'], ['class' => 'form-control selectpicker']));
return parent::edit($ids);
}
}