Level 13
Something like below check,
$items = Items::where('$collection1->id', '!=', '$collection2->id')->get();
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I've two collection.
$collection1 = [
'id' => 1,
'id' => 2,
'id' => 3
];
$collection2 = [
'id' => 7,
'id' => 2,
'id' => 4
];
I want to remove items from $collection1 if an item is exists in $collection2.
In that case, item with id 2 would be removed.
$diff = $collection1->diff($collection2)
Please or to participate in this conversation.