主页

fastadmin逗号分割数据名称查询,附加关联列表数据 addtion函数

砚台词   IP属地: 青海
0 点赞 0阅读 1074
代码
$list = $this->model
                // ->with('sort')
                ->where($where)
                // ->where($pidWhere)
                // ->where("pid in ($str)")
                ->order($sort, $order)
                ->paginate($limit);
                 $fields = [
                        [
                        'field'=>'sort_ids',//关联数据字段
                        'primary'=>'id',//关联表主键
                        'display'=>'sort_title',//附加字段名称
                        'column'=>'title',//关联表中读取需要显示的字段,显示所有用"*"
                        // 'model'=>\app\common\model\store'',//关联模型
                        //  'name'=>'Houseconfig',//模型名称,比table字段少一个前缀
                        'table'=>'c_sort',//关联表,关联表和关联模型二选一
                        // 'table'=>'h_house_config',//关联表,关联表和关联模型二选一
                        // 'type'=>'hasOne',//关联类型
                        // 'foreignKey'=>'house_config_id',//关联外键
                        // 'fields'=>['name']
                        ]
                    ];
                    // 关联查询逗号
                    addtion($list->items(), $fields);
            $rows = $list->items();

效果


© 著作权归作者所有,转载或内容合作请联系作者