Return 未删除帖子的评论
Return the comment for non deleted posts
如何只获取非软删除商家的位置。
- 我有
Location
和 Merchant
个模型。
- 每个商家都有很多位置。
当我得到位置时:
$locations = \App\Location::where('merchant_id', $merchantId)->get();
它 return 的位置,即使商家被软删除!
我怎样才能防止这种情况发生,所以如果商家被软删除,它就不会 return 位置?
您的 Location
必须实施 belongsTo()
到 Merchant
。然后在查询中添加has()
条件。
$locations = \App\Location::where('merchant_id', $merchantId)
->has('merchant')
->get();
如何只获取非软删除商家的位置。
- 我有
Location
和Merchant
个模型。 - 每个商家都有很多位置。
当我得到位置时:
$locations = \App\Location::where('merchant_id', $merchantId)->get();
它 return 的位置,即使商家被软删除!
我怎样才能防止这种情况发生,所以如果商家被软删除,它就不会 return 位置?
您的 Location
必须实施 belongsTo()
到 Merchant
。然后在查询中添加has()
条件。
$locations = \App\Location::where('merchant_id', $merchantId)
->has('merchant')
->get();