Skip to content

Commit 8f85ba2

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents de84512 + e74ead3 commit 8f85ba2

File tree

1 file changed

+102
-104
lines changed

1 file changed

+102
-104
lines changed

README.md

Lines changed: 102 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ Insert and update batch (bulk) in laravel
1313

1414
# Service Provider
1515

16-
file app.php in array providers :
16+
File `app.php` in array providers:
1717

1818
`Mavinoo\Batch\BatchServiceProvider::class,`
1919

2020
# Aliases
2121

22-
file app.php in array aliases :
22+
File `app.php` in array aliases:
2323

2424
`'Batch' => Mavinoo\Batch\BatchFacade::class,`
2525

@@ -30,31 +30,31 @@ use App\Models\User;
3030

3131
$userInstance = new User;
3232
$arrays = [
33-
[
34-
'conditions' => ['id' => 1, 'status' => 'active'],
35-
'columns' => [
36-
'status' => 'invalid'
37-
'nickname' => 'mohammad'
38-
],
39-
],
40-
[
41-
'conditions' => ['id' => 2],
42-
'columns' => [
43-
'nickname' => 'mavinoo',
44-
'name' => 'mohammad',
45-
],
46-
],
47-
[
48-
'conditions' => ['id' => 3],
49-
'columns' => [
50-
'nickname' => 'ali'
51-
],
52-
],
33+
[
34+
'conditions' => ['id' => 1, 'status' => 'active'],
35+
'columns' => [
36+
'status' => 'invalid',
37+
'nickname' => 'mohammad',
38+
],
39+
],
40+
[
41+
'conditions' => ['id' => 2],
42+
'columns' => [
43+
'nickname' => 'mavinoo',
44+
'name' => 'mohammad',
45+
],
46+
],
47+
[
48+
'conditions' => ['id' => 3],
49+
'columns' => [
50+
'nickname' => 'ali',
51+
],
52+
],
5353
];
5454
$keyName = 'id';
5555

5656
Batch::updateMultipleCondition($userInstance, $arrays, $keyName);
57-
or
57+
// or
5858
batch()->updateMultipleCondition($userInstance, $arrays, $keyName);
5959
```
6060

@@ -65,21 +65,21 @@ use App\Models\User;
6565

6666
$userInstance = new User;
6767
$value = [
68-
[
69-
'id' => 1,
70-
'status' => 'active',
71-
'nickname' => 'Mohammad'
72-
] ,
73-
[
74-
'id' => 5,
75-
'status' => 'deactive',
76-
'nickname' => 'Ghanbari'
77-
] ,
68+
[
69+
'id' => 1,
70+
'status' => 'active',
71+
'nickname' => 'Mohammad',
72+
],
73+
[
74+
'id' => 5,
75+
'status' => 'deactive',
76+
'nickname' => 'Ghanbari',
77+
],
7878
];
7979
$index = 'id';
8080

8181
Batch::update($userInstance, $value, $index);
82-
or
82+
// or
8383
batch()->update($userInstance, $values, $index);
8484
```
8585

@@ -90,29 +90,29 @@ use App\Models\User;
9090

9191
$userInstance = new User;
9292
$value = [
93-
[
94-
'id' => 1,
95-
'status' => 'active'
96-
],
97-
[
98-
'id' => 5,
99-
'status' => 'deactive',
100-
'nickname' => 'Ghanbari'
101-
],
102-
[
103-
'id' => 10,
104-
'status' => 'active',
105-
'date' => Carbon::now()
106-
],
107-
[
108-
'id' => 11,
109-
'username' => 'mavinoo'
110-
]
93+
[
94+
'id' => 1,
95+
'status' => 'active',
96+
],
97+
[
98+
'id' => 5,
99+
'status' => 'deactive',
100+
'nickname' => 'Ghanbari',
101+
],
102+
[
103+
'id' => 10,
104+
'status' => 'active',
105+
'date' => Carbon::now(),
106+
],
107+
[
108+
'id' => 11,
109+
'username' => 'mavinoo',
110+
],
111111
];
112112
$index = 'id';
113113

114114
Batch::update($userInstance, $value, $index);
115-
or
115+
// or
116116
batch()->update($userInstance, $values, $index);
117117
```
118118

@@ -123,31 +123,31 @@ use App\Models\User;
123123

124124
$userInstance = new User;
125125
$value = [
126-
[
127-
'id' => 1,
128-
'balance' => ['+', 500] // Add
129-
] ,
130-
[
131-
'id' => 2,
132-
'balance' => ['-', 200] // Subtract
133-
] ,
134-
[
135-
'id' => 3,
136-
'balance' => ['*', 5] // Multiply
137-
] ,
138-
[
139-
'id' => 4,
140-
'balance' => ['/', 2] // Divide
141-
] ,
142-
[
143-
'id' => 5,
144-
'balance' => ['%', 2] // Modulo
145-
] ,
126+
[
127+
'id' => 1,
128+
'balance' => ['+', 500], // Add
129+
],
130+
[
131+
'id' => 2,
132+
'balance' => ['-', 200], // Subtract
133+
],
134+
[
135+
'id' => 3,
136+
'balance' => ['*', 5], // Multiply
137+
],
138+
[
139+
'id' => 4,
140+
'balance' => ['/', 2], // Divide
141+
],
142+
[
143+
'id' => 5,
144+
'balance' => ['%', 2], // Modulo
145+
],
146146
];
147147
$index = 'id';
148148

149149
Batch::update($userInstance, $value, $index);
150-
or
150+
// or
151151
batch()->update($userInstance, $values, $index);
152152
```
153153

@@ -158,44 +158,44 @@ use App\Models\User;
158158

159159
$userInstance = new User;
160160
$columns = [
161-
'firstName',
162-
'lastName',
163-
'email',
164-
'isActive',
165-
'status',
161+
'firstName',
162+
'lastName',
163+
'email',
164+
'isActive',
165+
'status',
166166
];
167167
$values = [
168-
[
169-
'Mohammad',
170-
'Ghanbari',
171-
172-
'1',
173-
'0',
174-
] ,
175-
[
176-
'Saeed',
177-
'Mohammadi',
178-
179-
'1',
180-
'0',
181-
] ,
182-
[
183-
'Avin',
184-
'Ghanbari',
185-
186-
'1',
187-
'0',
188-
] ,
168+
[
169+
'Mohammad',
170+
'Ghanbari',
171+
172+
'1',
173+
'0',
174+
],
175+
[
176+
'Saeed',
177+
'Mohammadi',
178+
179+
'1',
180+
'0',
181+
],
182+
[
183+
'Avin',
184+
'Ghanbari',
185+
186+
'1',
187+
'0',
188+
],
189189
];
190190
$batchSize = 500; // insert 500 (default), 100 minimum rows in one query
191191

192192
$result = Batch::insert($userInstance, $columns, $values, $batchSize);
193-
or
193+
// or
194194
$result = batch()->insert($userInstance, $values, $index);
195195
```
196196

197197
```php
198-
// result : false or array
198+
// result: false or array
199199

200200
sample array result:
201201
Array
@@ -237,12 +237,10 @@ User::batchInsert($columns, $values, $batchSize);
237237

238238
```php
239239
// ex: update
240-
241240
$result = batch()->update($userInstance, $value, $index);
242241

243242

244243
// ex: insert
245-
246244
$result = batch()->insert($userInstance, $columns, $values, $batchSize);
247245
```
248246

0 commit comments

Comments
 (0)