fastadmin 关联预载入限制关联表的字段的显示:$v->hidden(['roominfo'=>['builtup_area','carpet_area', 'addons']]);
public function index() { //设置过滤方法 $this->request->filter(['strip_tags', 'trim']); if ($this->request->isAjax()) { //如果发送的来源是Selectpage,则转发到Selectpage if ($this->request->request('keyField')) { return $this->selectpage(); } list($where, $sort, $order, $offset, $limit) = $this->buildparams(); $list = $this->model ->with(['roominfo']) ->where($where) ->order($sort, $order) ->paginate($limit); foreach ($list as $k=>$v) { //$v->avatar = $v->avatar ? cdnurl($v->avatar, true) : letter_avatar($v->nickname); $v->hidden(['roominfo'=>['builtup_area','carpet_area', 'addons']]); //$row->visible(['builtup_area','carpet_area','deposit']); } $result = array("total" => $list->total(), "rows" => $list->items()); return json($result); } return $this->view->fetch(); }