模型关联排序问题

浏览:308 发布日期:2021/04/29 分类:ThinkPHP6专区 关键字: 关联模型排序
我想使用 techlist 中的数据来是self 主模型排序 怎么使用啊?或者是不能这样做吗?$item = self::with(['techlist'=>function($query){
                    $query->with(['project'=>function($q){
                        $q->with('projectName')->where('is_recommend',1)
                            ->orderRaw('rand()')
                            ->field('project_id,id,tech_id');
                    }])->orderRaw('rand(),sort desc')
                    ->field('id,store_id,avatar,nickname,en_name');
                }])->field($field)
                ->find($id);
最佳答案
评论( 相关
后面还有条评论,点击查看>>