assign('breadcrumb1','系统');
$this->assign('breadcrumb2','基础配置');
}
/**
* 列表页
*
* */
public function index(Model $Model){
// 超管可以管理所有
$map = in_array(admin('uid'), explode(',', config('administrator'))) ? [] : [['is_settings','=','1']];
// 查询用户
$list = $Model->query()->where($map)->paginate(config('page_num',10))->appends(request()->all());
// 分配数据
$this->assign('list',$list);
$this->assign('empty', '
~~暂无数据 |
');
// 加载模板
return $this->fetch();
}
/**
* 修改
*
* */
public function edit(Model $Model){
// 接受参数
$id = request('id',0);
// 查询数据
$oldData = $Model->query()->find($id);
// 修改
if(request()->isMethod('post')){
// 组合数据
$data['value'] = request('value','');
// 写入
$result = $Model->edit($id,$data);
// 提示新增失败
if( !$result ) return json_send(['code'=>'error','msg'=>'修改失败']);
// 记录行为
$this->addAdminHistory(admin('uid'),$Model->getTable(),$id,2,$oldData,$data);
// 告知结果
return json_send(['code'=>'success','msg'=>'修改成功','action'=>'edit']);
}
// 如果是没有数据
if( !$oldData ) return $this->error('查无数据');
// 分配数据
$this->assign('crumbs','修改'.$oldData['info']);
$this->assign('oldData',$oldData);
// 加载模板
return $this->fetch();
}
}