Tuesday, September 28, 2021

laravel 8 data_fill

 $data = [

    'products' => [

        ['name' => 'Desk 1', 'price' => 100],

        ['name' => 'Desk 2'],

    ],

];


data_fill($data, 'products.*.price', 200);


/*

    [

        'products' => [

            ['name' => 'Desk 1', 'price' => 100],

            ['name' => 'Desk 2', 'price' => 200],

        ],

    ]

*/

No comments:

Post a Comment