我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

Laravel得到多对多的范围

I want to filter all my users who ordered amount of orders in range so

User::where('type','client')
->whereHas('orders',function ($query) use($min_orders,$max_orders){

})

any solution??

You could use has() filter to filter out users with min and max count of associated orders

User::where('type','client')
    ->has('orders', '>=', $min_orders)
    ->has('orders', '<=', $max_orders)
    ->get()

See Querying Relationship Existence

近期文章

  • 求帮我看看,这怎么出错了
  • 代码标红问题,分号标红问题
  • sum在switch的作用域外面也可以输出,为什么会输出末尾的sum?
  • Tomcat运行不了怎么修改?
  • 关于Python的问题
  • webstorm 怎么解决没有html代码提示的问题
  • 关于函数、素数表的问题,如何解决?
  • 微信小程序地图运动轨迹计步
  • C#用GDI+实现在窗体上点击任意两点绘制一条直线
  • C++运行时出现Debug Error
  • 如何检测$ result是mysql_fetch_array($ result)中有效的MySQL结果资源
  • Mac安装jdk不成功
  • 这个有什么问题啊,真的做不出来了
  • 计算机竞赛怎么准备呢?怎样分配好时间呢?
  • 请教各位,刚学不明白为什么这样
  • Python下载又不行了!气大
  • 为什么这里写了一个jsp的程序运行不出来,显示我404错误?
  • 描述linux 中的共享内存。SHMMAX 、SHMMNI 、SHMALL 参数各代表什么?
  • Tableau上传Public问题
  • 怎么用MATLAB的循环删掉矩阵数据中的一些不需要的数据

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华