laravel orWhereHas查询关联关系的or查询

// 查询当前门店或者未被指派的门店
$model = $model->with(['userSystem'])->orWhereHas('userSystem',function($q) use($shop_id) {
                    $q->where('shop_id', $shop_id);
                });
                $model = $model->orWhereNull('sys_user_id');

你可能感兴趣的:(PHP,laravel)