PHP code example of jhavenz / laravel-batch-update

1. Go to this page and download the library: Download jhavenz/laravel-batch-update library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

jhavenz / laravel-batch-update example snippets


use Jhavenz\LaravelBatchUpdate\BatchedUpdate;

// 
(new BatchedUpdate(User::class))->update(
    values: [
        [
            'user_id' => 123,
            'name' => 'john doe',
            'email' => '[email protected]',
        ],
        [
            'user_id' => 234,
            'name' => 'jane doe',
            'email' => '[email protected]',
        ],
        // ... a whole bunch of mapped data (in memory), then 1 query gets executed
    ],
    index: <string> /** Give an index here, or leave null and the Model's key will be used  */
    quoted: <bool> /** have you quoted the value, or should I ?..   */
);