laravel-mongodb
laravel-mongodb copied to clipboard
Unset array replacing with null
foreach ($event->volunteers as $key => $volunteer) { if ($volunteer['user_id'] == $userId) { $event->where('volunteers.user_id', intval($userId)) ->unset("volunteers.$key"); } }
Here is my DB structure
"volunteers" : [ null, { "user_id" : NumberInt(1), "name" : "Prafful Panwar", "skills" : [ "Plumber" ], "incentives" : { "tshirt_size" : "XXL" }, "ready_to_contribute_min_amount" : "Yes", "attendance_status" : false } ],
Up!
@prafful-panwar try to use $pull instead of $unset.
Fixed by #2578