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

《L05 电商实战》
从零开发一个电商项目,功能包括电商后台、商品 & SKU 管理、购物车、订单管理、支付宝支付、微信支付、订单退款流程、优惠券等
《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
最佳答案

模型关联《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);
2年前 评论
讨论数量: 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);
2年前 评论
抄你码科技有限公司

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

site:learnku.com 关键词

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

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

模型关联《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);
2年前 评论