使用雄辩获取所有未包含的项目
我有以下表:
orders:
- id
- date
item_order:
- order_id
- item_id
items:
- id
- desc
- price
使用雄辩,我如何获取所有未包含在给定订单中的项目(例如,带有id
= 6的订单)?
我正在尝试建立关系&亚Queries,但没有运气。
提前致谢。
I have the following tables:
orders:
- id
- date
item_order:
- order_id
- item_id
items:
- id
- desc
- price
Using Eloquent, how can I get all the items NOT included in a giving order (say, the order with id
= 6)?
I'm trying to do relationships & subqueries, but without luck.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论
评论(1)
您的问题还不够清楚,
使用雄辩,我如何获取所有未包含的项目(例如,ID = 6的订单)?
,此句子尚不清楚。另一方面,基于您的说明,下面的示例将返回带有其项目的订单列表,除了您不想要的内容:
您将获得
订单
的列表,带有item_order
但您将不会获得item_order
,用于订单,ID为6。如果不是您所要求的,请澄清并更新您的问题以更好地说明。
根据您的评论:
您的解决方案给了我订单,但是我想要所有项目,除了具有ID = 6的订单外,您可以简单地用指定的模型和关系替换查询
Your question is not clear enough,
Using Eloquent, how can I get all the items NOT included in a giving order (say, the order with id = 6)?
, this sentence is unclear.In other hand based on your explanation, below example gonna return list of orders with their items, except something you don't want:
You will get list of
orders
withitem_order
but you will not getitem_order
for order with id of 6.If this is not what you've asked please clarify and update your question for better explanation.
Based on your comment :
Your solution gives me the ORDERS, but I want all the ITEMS, except those of the order with id = 6.
, you can simply replace query with specified model and relations