Laravel hasMany,with 如何带动态条件?
在with的时候能否添加一个动态条件来筛选。
$order = Order::query();
$data = $order->with(['services'=>function($query){
$query->where(['service.status'=>0]);
}])->get()->toArray();
我这样写条件没有进行筛选,还是全部查出来了。
求指教
推荐文章: