在控制器*工作内容*中为您简单介绍了getList属性
> 3. 根据子类的getList属性自动获取模型对象。
以及getList函数(或方法)
> 5. 已设计好getList()函数(或方法),可提供layui框架的data-table获取列表参数。并根据子类的getListWith属性获取关联数据
如下面代码所示,在其中用到model属性,而model属性的生成是获取到了getList属性的值,而在getList()方法中,使用了
```
Model::all(function(){},$this->getListWith)
```
以上代码,既说明geListWith是支持字符串与字符串数组的。
### 参考代码:
```
/**
* 初始化model
*/
private function setModel()
{
$this->model = $this->{'model'.$this->getList};
}
/**
* 获取列表通用方法
* @return mixed
* @throws \think\exception\DbException
*/
public function getList()
{
$where = [];
$model = 'model'.$this->getList;
foreach (input() as $k => $w ){
if (($k=='page' ||$k=='limit')){
continue;
}
if ($w) $where[$this->model->getTable().'.'.$k] = $w;
}
$qcms = ($this->model)::all(function (Query $query) use ($where){
$query->where($where)->page(input('page')?:1)->limit(input('limit')?:10);
},$this->getListWith ? : null);
$data = LayuiListApiService::getData(($this->$model)->count(),$qcms);
return $data;
}
```