I have a MongoDB collection, with documents that have an array field with objects. I need to delete a specific object when 2 properties match.
I've tried using pull https://laravel.com/docs/master/collections#method-pull
but it only allows me to remove the whole document property, or I'm using it wrong.
$node = Node::where('ports.number', $portNumber)->where('ports.ip', $portIp)->first();
Now I want to delete the port object inside the ports[] if the number and IP matches. Something like this, but with Eloquent:
if($ip && $number){
unset($ports[$key])
}
Any comment appreciated.
Nodeand you wrote you want to removeportobject. What is the relationship between these two items?