我想从集合中移除已过滤的集合,例如我有此返回的集合。筛选集合并删除集合雄辩laravel
$products = items::where('item_id',$request->item_id)->with('product_reviews')->with('product_reviews.profile')->get();
foreach($products->product_reviews as $r):
if($r->status==='unapproved'):
//remove this from 'products' collections because its not approved yet
$this->remove($this);
endif;
endforeach;
但这
$this->remove($this);
不工作,既不是有效的语法删除图片集,我只是不知道如何例如去除过滤收集如果列状态包含“未批准”。任何想法,请帮助吗?
为什么你不包括另一个考虑状态? – ggderas
你可以在我的给定代码片段上发布示例基础吗? –
我不知道该怎么做,因为我的目标是属于项目模型的产品。 –