with的文档怎么不见了?另外with怎么嵌套where?

with的文档,在《Laravel 9 中文文档》 怎么找不到了?

另外,我需求在with里嵌套where要怎么弄

$allLsit = UserIdentStatus::where('ident_status', 10)
->with('user_ident_by_company:id,user_id,store_pic,company_name','merchant_goods')
->where('company_name',  'like',  '%'.$keyword.'%')
->orderBy('created_at', 'desc')
->paginate(4);

现在这么写,查询不到,因为company_nameuser_ident_by_company

《L01 基础入门》
我们将带你从零开发一个项目并部署到线上,本课程教授 Web 开发中专业、实用的技能,如 Git 工作流、Laravel Mix 前端工作流等。
《G01 Go 实战入门》
从零开始带你一步步开发一个 Go 博客项目,让你在最短的时间内学会使用 Go 进行编码。项目结构很大程度上参考了 Laravel。
最佳答案

模型关联《Laravel 9 中文文档》

$allLsit = UserIdentStatus::whereHas('user_ident_by_company', function ($query) {
    $query->where('company_name',  'like',  '%'.$keyword.'%');
})
->where('ident_status', 10)
->with('user_ident_by_company:id,user_id,store_pic,company_name','merchant_goods')
->orderBy('created_at', 'desc')
->paginate(4);
1年前 评论
讨论数量: 4
$allLsit = UserIdentStatus::where('ident_status', 10)
->with('user_ident_by_company:id,user_id,store_pic,company_name','merchant_goods'=>function($query){
    $query->where('id',1);
})
->where('company_name',  'like',  '%'.$keyword.'%')
->orderBy('created_at', 'desc')
->paginate(4);
1年前 评论
抄你码科技有限公司

站内搜索感觉不好用,百度orgoogle搜索时可以用下面的骚操作

site:learnku.com 关键词

模型关联《Laravel 9 中文文档》

1年前 评论
wongvio (楼主) 1年前

模型关联《Laravel 9 中文文档》

$allLsit = UserIdentStatus::whereHas('user_ident_by_company', function ($query) {
    $query->where('company_name',  'like',  '%'.$keyword.'%');
})
->where('ident_status', 10)
->with('user_ident_by_company:id,user_id,store_pic,company_name','merchant_goods')
->orderBy('created_at', 'desc')
->paginate(4);
1年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!