Comments (9)
for use ::
use Mavinoo\LaravelBatch\LaravelBatchFacade as Batch;
from laravelbatch.
Hi
What is the output of this function?
$this->createUpdateBankObject($request, $selected)
Like this do
$array = [
[
'id' => 1,
'name' => 'mohammad'
],
[
'id' => 10,
'name' => 'Cholowao'
],
[
'id' => 20,
'username' => 'cholowao'
]
];
Batch::update( 'NameTable' , $array , 'id' );
Please https://github.com/mavinoo/laravelBatch/blob/master/README.md
from laravelbatch.
private function createUpdateBankObject($request, $selected) {
$update = [];
foreach ($request->all() as $key => $request) {
if (!in_array($request['id'], $selected)) {
continue;
}
$arr = array(
'bank_id' => $request['id'],
'account_no' => $request['account_no'],
);
$update[] = $arr;
}
return $update;
}
with output
[
{
"bank_id": 1,
"account_no": "34534758"
}
]
from laravelbatch.
I tried your example and use Batch;
and the top. But still "message": "Class 'Batch' not found",
did I missed installation steps.
from laravelbatch.
example :
private function createUpdateBankObject($request, $selected)
{
$update = [];
foreach ($request->all() as $key => $request)
{
if (!in_array($request['id'], $selected))
{
continue;
}
$arr = array(
'bank_id' => $request['id'],
'account_no' => $request['account_no'],
);
$update[] = $arr;
}
return $update;
}
$requests = [
[
'id' => 10,
'account_no' => 'ok'
],
[
'id' => 1,
'account_no' => '34534758'
],
[
'id' => 20,
'account_no' => 'ok'
],
];
$selected = [1];
echo '<pre/>';
print_r(createUpdateBankObject($requests, $selected));
output :
Array
(
[0] => Array
(
[bank_id] => 1
[account_no] => 34534758
)
)
in Batch:
Batch::update('bank_school' , createUpdateBankObject($requests, $selected)) , 'bank_id');
from laravelbatch.
I am using it in the controller. Here is my 'header'
<?php
namespace App\Http\Controllers\Banks;
use App\BankSchool;
use App\Http\Controllers\Controller;
use App\Http\Controllers\HelperController as Helper;
use Mavinoo\LaravelBatch\LaravelBatchFacade as Batch;
use Illuminate\Http\Request;
...
but strangely, it changed to Class Batch does not exist
from laravelbatch.
please change to
use Mavinoo\LaravelBatch as Batch;
!!
from laravelbatch.
It says Class 'Mavinoo\LaravelBatch' not found
from laravelbatch.
For some reason I failed to do importing
but instead I created a class in my App\Controller\Banks
and pasted codes from your src
and it worked like a charm!
Thanks for the source.
from laravelbatch.
Related Issues (20)
- updateWithTwoIndex not support increment / decrement
- If text with double quotes cannot be escaped
- New release? HOT 1
- updateWithTwoIndex not creating new record if not exist HOT 2
- updateWithThreeIndex HOT 2
- 额外添加的updated_at
- How about binding parameters? HOT 1
- Why not implement update by unlimited multiple colums in where clause? HOT 1
- ParseError: syntax error, unexpected 'return' (T_RETURN) in version 2.3.2, 2.3.3. HOT 3
- syntax error, unexpected 'return' (T_RETURN) HOT 3
- Does it work with laravel 9? Did not work with laravel 9 in my project. 🐛 HOT 2
- Request for new version HOT 2
- the new releases after 2.3.1 has a bug in file Batch.php - Insert Function HOT 2
- Syntax error, unexpected token "return" :: 275 line HOT 3
- Syntax error caused by single quotes in a json string HOT 1
- PHP 7.4 run Batch::update syntax error Batch.php:275
- how to update with pivot tables?
- Update rows with single quote
- Its possible to deactivate timestamps? HOT 1
- Non-static method Mavinoo\\Batch\\Batch::update() cannot be called statically HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravelbatch.