Coder Social home page Coder Social logo

Class 'Batch' not found about laravelbatch HOT 9 CLOSED

mavinoo avatar mavinoo commented on August 20, 2024
Class 'Batch' not found

from laravelbatch.

Comments (9)

mavinoo avatar mavinoo commented on August 20, 2024 2

for use ::

use Mavinoo\LaravelBatch\LaravelBatchFacade as Batch;

from laravelbatch.

mavinoo avatar mavinoo commented on August 20, 2024

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.

Cholowao avatar Cholowao commented on August 20, 2024
	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.

Cholowao avatar Cholowao commented on August 20, 2024

I tried your example and use Batch; and the top. But still "message": "Class 'Batch' not found", did I missed installation steps.

from laravelbatch.

mavinoo avatar mavinoo commented on August 20, 2024

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.

Cholowao avatar Cholowao commented on August 20, 2024

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.

mavinoo avatar mavinoo commented on August 20, 2024

please change to

use Mavinoo\LaravelBatch as Batch;

!!

from laravelbatch.

Cholowao avatar Cholowao commented on August 20, 2024

It says Class 'Mavinoo\LaravelBatch' not found

from laravelbatch.

Cholowao avatar Cholowao commented on August 20, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.