Skip to content

Unset array replacing with null #1506

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
prafful-panwar opened this issue May 1, 2018 · 3 comments
Closed

Unset array replacing with null #1506

prafful-panwar opened this issue May 1, 2018 · 3 comments

Comments

@prafful-panwar
Copy link

prafful-panwar commented May 1, 2018

            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
        }
    ],
@FabianoLothor
Copy link

Up!

@FabianoLothor
Copy link

@prafful-panwar try to use $pull instead of $unset.

@GromNaN
Copy link
Member

GromNaN commented Aug 28, 2023

Fixed by #2578

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants