Laravel- How to Remove a key from collection?

  laravel, laravel-collection

I have data as below:

[
        {
            "id": "3",
            "title": "Boruto's Photo",
            "is_lottery": 1,
            "price": 10
        },
        {
            "id": "4",
            "title": "Misuki's Photo",
            "is_lottery": 0,
            "price": 20
        }

    ]

I want to filter which is is_lottery == false remove the price key from this collection. The output is:

[
        {
            "id": "3",
            "title": "Boruto's Photo",
            "is_lottery": 1,
            "price": 10
        },
        {
            "id": "4",
            "title": "Misuki's Photo",
            "is_lottery": 0,
        }

    ]

Source: Laravel

Leave a Reply