fastadmin加外接表
1. 加第一行設定,with裡面,隔開關聯的表對應的方法在model裡面
protected $relationSearch = true; public function index() { //設定過濾方法 $this->request->filter(['strip_tags']); if ($this->request->isAjax()) { //如果傳送的來源是Selectpage,則轉發到Selectpage if ($this->request->request('keyField')) { return $this->selectpage(); } list($where, $sort, $order, $offset, $limit) = $this->buildparams(); $total = $this->model ->with("Member,circle") ->where($where) ->order($sort, $order) ->count();
2.model裡面寫對應的方法,()裡表名,原表的id,外接表id,連線型別
public function member() { return $this->belongsTo('Member', 'mid','id','left')->setEagerlyType(0); }
3.前端js顯示
{field: 'member.realname', title: __('Mid')},