我想從集合中移除已過濾的集合,例如我有此返回的集合。篩選集合並刪除集合雄辯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
你可以在我的給定代碼片段上發佈示例基礎嗎? –
我不知道該怎麼做,因爲我的目標是屬於項目模型的產品。 –