mavinoo / laravelBatch

insert batch and update batch in laravel
MIT License
571 stars 118 forks source link

Dealing with object/array values #83

Closed ianrussel closed 2 years ago

ianrussel commented 2 years ago

Hi, I tries this package to bulk update records, it works well if the values in array is string or numbers, however if the values is object or array I got error

          ` Increment/Decrement array needs to have 2 values, a math operator (+, -, *, /, %) and a number

            at vendor/mavinoo/laravel-batch/src/Batch.php:88
           `

This is the format of data

            [
                [
                    "id": 103,
                    "fees": {
                        "Principal": 24.95,
                        "Commission": -1.75
                    ],
                    "updated_at": "2022-02-25 08:08:52",
                    "with_financial_events": 1,
                    "total_fee": -4.62,
                    "refunded": 0,
                    "total_refund": 0,
                    "chargeback": 0,
                    "units": "1",
                    "vat": 3.98,
                    "cogs": 5.49,
                    "total_sales": 24.95,
                    "gross_profit": 10.859999999999998
                ],
                [
                    "id": 104,
                    "fees": {
                        "Principal": 24.95,
                        "Commission": -1.75
                    ],
                    "updated_at": "2022-02-25 08:08:52",
                    "with_financial_events": 1,
                    "total_fee": -4.62,
                    "refunded": 0,
                    "total_refund": 0,
                    "chargeback": 0,
                    "units": "1",
                    "vat": 3.98,
                    "cogs": 5.49,
                    "total_sales": 24.95,
                    "gross_profit": 10.859999999999998
                [,

As you can see, the key fees inside array is object

Zain541 commented 1 year ago

Hey! How did you solve this issue?