Laravel检查是否包含属于属于的属于
在我的系统中:
- 铅属于属于销售人员,
- 经理属于属于销售人员,
我正在尝试检查铅是否通过销售人员拥有经理。这是针对政策的,因此我可以确保经理可以看到其销售人员的潜在客户。
这样的事情:
$lead->salespeople->contains($manager->salespeople)
是否有一种收集方法可以让我这样做?我还尝试了类似的东西也不有效:
$lead->salespeople->contains('id', $manager->salespeople->pluck('id')->toArray())
编辑,我想我明白了。这看起来正确吗?:
$lead->salespeople->intersect($manager->salespeople)->count() > 0
in my system:
- a lead belongstomany salespeople
- a manager belongstomany salespeople
i am trying to check if a lead has a manager through the salespeople. this is for a policy so i can make sure a manager can see the leads of their salespeople.
something like this:
$lead->salespeople->contains($manager->salespeople)
is there a collection method that will allow me to do this? i've also tried stuff like this which isn't working either:
$lead->salespeople->contains('id', $manager->salespeople->pluck('id')->toArray())
edit, i think i got it. does this look correct?:
$lead->salespeople->intersect($manager->salespeople)->count() > 0
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最终使用此软件包解决了这个问题: https://githbithub.com/staudenmeir/eloquent/eloquent/eloquent/eloquent/eloquent/eloquent/eloquent/eloquent/eloquent/eloquent- -has-the-Deap
这是我的关系方法:
Ended up solving this problem with this package: https://github.com/staudenmeir/eloquent-has-many-deep
Here's my relationship method now: