fastadmin
Posted 顾笙言啊顾笙言
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了fastadmin相关的知识,希望对你有一定的参考价值。
1.结构 list+total
return [\'list\' => $list, \'total\' => $total];
list需要用limit分页,页码字段是pageNumber
2.赋值
如果获取到keyValue的值的话就根据值来做相应的where条件
在编辑页面初始化页面的时候,第一次会将关联id作为keyValue传到后台,点击选择框之后的异步调用则不会传keyValue
3.示例
public function query() { $account = Admin::get($this->auth->id); $page = $this->request->request(\'pageNumber\')?:1; $param = input(); $id = (isset($param[\'keyValue\'])&&$param[\'keyValue\'])>0?$param[\'keyValue\']:0; $zhi = 10; $tiao = ($page-1)*$zhi; $where = [\'status\' => \'normal\']; if($account[\'position_ids\']!="all"&&$account[\'position_ids\']!=""){ $where[\'position_id\'] = ["IN",$account[\'position_ids\']]; } if($id>0){ $where[\'id\'] = $id; } if($param[\'username\']!="") $where[\'username\'] = [\'like\',"%{$param[\'username\']}%"]; $list = Db::name("user")->where($where)->field("id,username,position_id")->limit($tiao,$zhi)->select(); $total = Db::name("user")->where($where)->field("id,username,position_id")->count(); return [\'list\' => $list, \'total\' => $total]; }
以上是关于fastadmin的主要内容,如果未能解决你的问题,请参考以下文章