Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我在Laravel Excel 3.1队列导入中出错_Laravel_Laravel Excel_Laravel Queue - Fatal编程技术网

我在Laravel Excel 3.1队列导入中出错

我在Laravel Excel 3.1队列导入中出错,laravel,laravel-excel,laravel-queue,Laravel,Laravel Excel,Laravel Queue,服务器环境 PHP7.4 maatwebsite/excel 3.1 我尝试使用与相关的队列导入,但我始终在工作队列上获得[2020-10-25 01:18:56][16]失败:Maatwebsite\Excel\Jobs\ReadChunk public function import(Request $request){ if (Auth::guard('web')->user()->hasRole('Collector')){ return abor

服务器环境

  • PHP7.4
  • maatwebsite/excel 3.1
我尝试使用与相关的队列导入,但我始终在工作队列上获得[2020-10-25 01:18:56][16]失败:Maatwebsite\Excel\Jobs\ReadChunk

public function import(Request $request){
    if (Auth::guard('web')->user()->hasRole('Collector')){
        return abort('404');
    }

    try {
        Excel::queueImport(new CustomerImport(),$request->file('import_file'));
        return back()->with('success','Upload Success');
    } catch (\Exception $exception) {
        return back()->with('danger','An Error when uploading file. Please try again');
    }
}
自定义导入文件

<?php

namespace App\Imports;

use App\Http\Controllers\Controller;
use App\Models\CustomerAddress;
use App\Models\CustomerEmergencyContact;
use App\Models\CustomerMainData;
use Illuminate\Contracts\Queue\ShouldQueue;
use Maatwebsite\Excel\Concerns\ToModel;
use Maatwebsite\Excel\Concerns\WithStartRow;
use Maatwebsite\Excel\Concerns\WithChunkReading;

class CustomerImport extends Controller implements ToModel, WithStartRow, WithChunkReading, ShouldQueue
{
    /**
    * @param array $row
    *
    * @return \Illuminate\Database\Eloquent\Model|null
    */
    public function model(array $row)
    {
        $data = CustomerMainData::where('contract_no',$row[6])->where('customer_code',$row[4])->first();
        if (empty($data)) {
            $data = new CustomerMainData([
                'assign_date' => $this->encodeThaiCarbon($row[0]),
                'expiry_date' => $this->encodeThaiCarbon($row[1]),
                'id_no' =>$row[2],
                'birth_date' => $this->encodeThaiCarbon($row[3]),
                'customer_code' => $row[4],
                'name' => $row[5],
                'contract_no' => $row[6],
                'contract_date' => $this->encodeThaiCarbon($row[7]),
                'wo_date' => $this->encodeThaiCarbon($row[8]),
                'contact_term' => $row[9],
                'installment_amount' => $row[10]/100,
                'over_due_status' => $row[11],
                'loan_amount' => $row[12]/100,
                'wo_balance' => $row[13]/100,
                'over_due_amount' => $row[14]/100,
                'penalty_amount' => $row[15]/100,
                'closing_amount' => $row[16]/100,
                'receive_status_od2' => $row[17],
                'receive_amount_before' => $row[18]/100,
                'receive_amount_after' => $row[19]/100,
                'last_pay_amount' => $row[20]/100,
                'last_pay_date' => $this->encodeThaiCarbon($row[21]),
                'no_assign' => $row[22],
                'product_desc' => $row[23],
                'provider_note' => $row[54],
                'loan_type' => $row[55],
                'oa_fee' => $row[59]/100,
                'max_oa_fee_amount' => $row[60]/100,
                'max_oa_fee_balance' => $row[61]/100,
                'oa_flag' => $row[62],
                'send_flag' => $row[63],
            ]);
        } else {
            $data->fill([
                'assign_date' => $this->encodeThaiCarbon($row[0]),
                'expiry_date' => $this->encodeThaiCarbon($row[1]),
                'id_no' =>$row[2],
                'birth_date' => $this->encodeThaiCarbon($row[3]),
                'name' => $row[5],
                'contract_date' => $this->encodeThaiCarbon($row[7]),
                'wo_date' => $this->encodeThaiCarbon($row[8]),
                'contact_term' => $row[9],
                'installment_amount' => $row[10]/100,
                'over_due_status' => $row[11],
                'loan_amount' => $row[12]/100,
                'wo_balance' => $row[13]/100,
                'over_due_amount' => $row[14]/100,
                'penalty_amount' => $row[15]/100,
                'closing_amount' => $row[16]/100,
                'receive_status_od2' => $row[17],
                'receive_amount_before' => $row[18]/100,
                'receive_amount_after' => $row[19]/100,
                'last_pay_amount' => $row[20]/100,
                'last_pay_date' => $this->encodeThaiCarbon($row[21]),
                'no_assign' => $row[22],
                'product_desc' => $row[23],
                'provider_note' => $row[54],
                'loan_type' => $row[55],
                'oa_fee' => $row[59]/100,
                'max_oa_fee_amount' => $row[60]/100,
                'max_oa_fee_balance' => $row[61]/100,
                'oa_flag' => $row[62],
                'send_flag' => $row[63],
            ]);
        }

        $data->save();
        $address = CustomerAddress::where('customer_main_data_id',$data->id)->first();

        if (empty($address)) {
            $address = new CustomerAddress([
                'customer_main_data_id' => $data->id,
                'home_address_1' => $row[24],
                'home_address_2' => $row[25],
                'home_address_3' => $row[26],
                'home_address_4' => $row[27],
                'home_telephone' => $row[28],
                'home_mobile' => $row[50],
                'office_address_1' => $row[29],
                'office_address_2' => $row[30],
                'office_address_3' => $row[31],
                'office_address_4' => $row[32],
                'office_telephone' => $row[33],
                'office_mobile' => $row[51],
                'identification_address_1' => $row[34],
                'identification_address_2' => $row[35],
                'identification_address_3' => $row[36],
                'identification_address_4' => $row[37],
                'identification_telephone' => $row[52],
                'identification_mobile' => $row[53],
            ]);
        } else {
            $address->fill([
                'home_address_1' => $row[24],
                'home_address_2' => $row[25],
                'home_address_3' => $row[26],
                'home_address_4' => $row[27],
                'home_telephone' => $row[28],
                'home_mobile' => $row[50],
                'office_address_1' => $row[29],
                'office_address_2' => $row[30],
                'office_address_3' => $row[31],
                'office_address_4' => $row[32],
                'office_telephone' => $row[33],
                'office_mobile' => $row[51],
                'identification_address_1' => $row[34],
                'identification_address_2' => $row[35],
                'identification_address_3' => $row[36],
                'identification_address_4' => $row[37],
                'identification_telephone' => $row[52],
                'identification_mobile' => $row[53],
            ]);
        }

        $address->save();
        $emergency_contact = CustomerEmergencyContact::where('customer_main_data_id',$data->id)->first();

        if (empty($emergency_contact)) {
            $emergency_contact = new CustomerEmergencyContact([
                'customer_main_data_id' => $data->id,
                'contact_name_1' => $row[38],
                'contact_phone_1' => $row[39],
                'contact_phone_ext_1' => $row[40],
                'contact_name_2' => $row[41],
                'contact_phone_2' => $row[42],
                'contact_phone_ext_2' => $row[43],
                'contact_name_3' => $row[44],
                'contact_phone_3' => $row[45],
                'contact_phone_ext_3' => $row[46],
                'contact_name_4' => $row[47],
                'contact_phone_4' => $row[48],
                'contact_phone_ext_4' => $row[49],
            ]);
        } else {
            $emergency_contact->fill([
                'contact_name_1' => $row[38],
                'contact_phone_1' => $row[39],
                'contact_phone_ext_1' => $row[40],
                'contact_name_2' => $row[41],
                'contact_phone_2' => $row[42],
                'contact_phone_ext_2' => $row[43],
                'contact_name_3' => $row[44],
                'contact_phone_3' => $row[45],
                'contact_phone_ext_3' => $row[46],
                'contact_name_4' => $row[47],
                'contact_phone_4' => $row[48],
                'contact_phone_ext_4' => $row[49],
            ]);
        }
        $emergency_contact->save();
        return $data;
    }

    public function startRow(): int
    {
        return 2;
    }

    public function chunkSize(): int
    {
        return 100;
    }
}

如何修复此错误。我试着修复了2天,但我无法

您是否能够修复此问题?
local.ERROR: Too few arguments to function Illuminate\Routing\Controller::middleware(), 0 passed in /Users/topkst/PhpstormProjects/easy-buy/vendor/maatwebsite/excel/src/Jobs/ReadChunk.php on line 101 and at least 1 expected {"exception":"[object] (ArgumentCountError(code: 0): Too few arguments to function Illuminate\\Routing\\Controller::middleware(), 0 passed in /Users/topkst/PhpstormProjects/easy-buy/vendor/maatwebsite/excel/src/Jobs/ReadChunk.php on line 101 and at least 1 expected at /Users/topkst/PhpstormProjects/easy-buy/vendor/laravel/framework/src/Illuminate/Routing/Controller.php:23)