All Projects → mavinoo → Laravelbatch

mavinoo / Laravelbatch

Licence: mit
insert batch and update batch in laravel

Projects that are alternatives of or similar to Laravelbatch

EFT Flea Market Bot
Escape from Tarkov Flea Market bot, to generate a lot of in-game currency within shortest time, while not even having to actively play the game!
Stars: ✭ 22 (-91.47%)
Mutual labels:  batch
openmessaging.github.io
OpenMessaging homepage
Stars: ✭ 12 (-95.35%)
Mutual labels:  batch
Laravel Email Campaigns
Send email campaigns using Laravel
Stars: ✭ 257 (-0.39%)
Mutual labels:  laravel
enableallExtensions
Automatically add all existing Chrome extensions to ExtensionInstallWhitelist, including non-webstore ones
Stars: ✭ 23 (-91.09%)
Mutual labels:  batch
chessalyzer.js
A JavaScript library for batch analyzing chess games
Stars: ✭ 14 (-94.57%)
Mutual labels:  batch
Fun
Small fun scripts
Stars: ✭ 22 (-91.47%)
Mutual labels:  batch
rocketjob
Ruby's missing background and batch processing system
Stars: ✭ 281 (+8.91%)
Mutual labels:  batch
Laravel Nova Excel
🚀 Supercharged Excel exports for Laravel Nova Resources
Stars: ✭ 259 (+0.39%)
Mutual labels:  laravel
nmly
Easy to use bulk rename utility for the terminal
Stars: ✭ 41 (-84.11%)
Mutual labels:  batch
Pt Br Validator
Uma biblioteca contendo validações de formatos Brasileiros, para o Laravel
Stars: ✭ 255 (-1.16%)
Mutual labels:  laravel
Bat2Exe
Windows user interface for converting your batch files into executables.
Stars: ✭ 60 (-76.74%)
Mutual labels:  batch
sidekiq-merger
Merge Sidekiq jobs
Stars: ✭ 49 (-81.01%)
Mutual labels:  batch
pronuncify
automate incrementally producing word pronunciation recordings for Wiktionary through Wikimedia Commons
Stars: ✭ 23 (-91.09%)
Mutual labels:  batch
Batched-Grabber
🖥️ Windows Batch and powershell Discord Token grabber. Made for Troll (lmao)
Stars: ✭ 39 (-84.88%)
Mutual labels:  batch
Old Lms Laravel
Laravel Learning Management System (LMS)
Stars: ✭ 258 (+0%)
Mutual labels:  laravel
svg2vector
Online batch converter of SVG images to Android vector drawable XML resource files
Stars: ✭ 39 (-84.88%)
Mutual labels:  batch
batch deobfuscator
Deobfuscate batch scripts obfuscated using string substitution and escape character techniques.
Stars: ✭ 82 (-68.22%)
Mutual labels:  batch
Yascmf
已过时,请访问5.2新版仓库
Stars: ✭ 258 (+0%)
Mutual labels:  laravel
S Cart
This project has been replaced by https://github.com/s-cart/s-cart
Stars: ✭ 258 (+0%)
Mutual labels:  laravel
ForzaHorizonFix
A simple fix for Forza Horizon 4 and Forza Horizon 5 crashes
Stars: ✭ 20 (-92.25%)
Mutual labels:  batch

Laravel BATCH (BULK)

Insert and update batch (bulk) in laravel

License Latest Stable Version Total Downloads Daily Downloads

Install

composer require mavinoo/laravel-batch

Service Provider

file app.php in array providers :

Mavinoo\Batch\BatchServiceProvider::class,

Aliases

file app.php in array aliases :

'Batch' => Mavinoo\Batch\BatchFacade::class,

Example Update 1

use App\Models\User;

$userInstance = new User;
$value = [
     [
         'id' => 1,
         'status' => 'active',
         'nickname' => 'Mohammad'
     ] ,
     [
         'id' => 5,
         'status' => 'deactive',
         'nickname' => 'Ghanbari'
     ] ,
];
$index = 'id';

Batch::update($userInstance, $value, $index);

Example Update 2

use App\Models\User;

$userInstance = new User;
$value = [
     [
         'id' => 1,
         'status' => 'active'
     ],
     [
         'id' => 5,
         'status' => 'deactive',
         'nickname' => 'Ghanbari'
     ],
     [
         'id' => 10,
         'status' => 'active',
         'date' => Carbon::now()
     ],
     [
         'id' => 11,
         'username' => 'mavinoo'
     ]
];
$index = 'id';

Batch::update($userInstance, $value, $index);

Example Increment / Decrement

use App\Models\User;

$userInstance = new User;
$value = [
     [
         'id' => 1,
         'balance' => ['+', 500] // Add
     ] ,
     [
         'id' => 2,
         'balance' => ['-', 200] // Subtract
     ] ,
     [
         'id' => 3,
         'balance' => ['*', 5] // Multiply
     ] ,
     [
         'id' => 4,
         'balance' => ['/', 2] // Divide
     ] ,
     [
         'id' => 5,
         'balance' => ['%', 2] // Modulo
     ] ,
];
$index = 'id';

Batch::update($userInstance, $value, $index);

Example Insert

use App\Models\User;

$userInstance = new User;
$columns = [
     'firstName',
     'lastName',
     'email',
     'isActive',
     'status',
];
$values = [
     [
         'Mohammad',
         'Ghanbari',
         '[email protected]',
         '1',
         '0',
     ] ,
     [
         'Saeed',
         'Mohammadi',
         '[email protected]',
         '1',
         '0',
     ] ,
     [
         'Avin',
         'Ghanbari',
         '[email protected]',
         '1',
         '0',
     ] ,
];
$batchSize = 500; // insert 500 (default), 100 minimum rows in one query

$result = Batch::insert($userInstance, $columns, $values, $batchSize);
// result : false or array

sample array result:
Array
(
    [totalRows]  => 384
    [totalBatch] => 500
    [totalQuery] => 1
)

Helper batch()

// ex: update

$result = batch()->update($userInstance, $value, $index);


// ex: insert

$result = batch()->insert($userInstance, $columns, $values, $batchSize);

Tests

If you don't have phpunit installed on your project, first run composer require phpunit/phpunit

In the root of your laravel app, run ./vendor/bin/phpunit ./vendor/mavinoo/laravel-batch/tests

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].