I have this old project with importing excel data to db,i am using laragon with latest version with php-7.4.19-Win32-vc15-x64
but the project is run with 7.1
in the server so i have used php-7.1.25-Win32-VC14-x64
this php version,but when i try to upload excel it throws this error I have searched also found using []
instead of {}
will fix the issue,but i have tried that, this is line where showed the error but i tried to use []
this but same error throws }); return back()->with('success', 'Your File Is Successfully Uploaded To Database!');
public function importExcel(Request $request)
{
if ($request->hasFile('import_file')) {
Excel::load($request->file('import_file')->getRealPath(), function ($reader) {
foreach ($reader->toArray() as $key => $row) {
$old_customer = Registration::where('customerid', $row['customerid'])->first();
if(count($old_customer)==0)
{
$data['customername'] = $row['customername'];
$data['chassis'] = $row['chassis'];
$data['model'] = $row['model'];
$data['branchcode'] = $row['branchcode'];
$data['delivery'] = $row['delivery'];
$data['customerid'] = $row['customerid'];
$data['phone'] = $row['phone'];
$data['invoicedate'] = $row['invoicedate'];
$registration_id = Registration::orderBy('registration_id', 'desc')->take(1)->get();
if (count($registration_id) > 0) {
$regid = $registration_id[0]->registration_id;
$regid = $regid + 1;
} else {
$regid = 1;
}
$register = new Registration();
$register->registration_id = $regid;
$register->customername = $row['customername'];
$register->chassis = $row['chassis'];
$register->model = $row['model'];
$register->branchcode = $row['branchcode'];
$register->delivery = $row['delivery'];
$register->customerid = $row['customerid'];
$register->phone = $row['phone'];
$register->invoicedate = $row['invoicedate'];
$register->created_user_id = Session::get('created_id');
$register->save();
$regidn = Registration::orderBy('registration_id', 'desc')->get();
$regidd = $regidn[0]->registration_id;
$ssitrack = new Ssi_track();
$ssitrack->registration_id = $regid;
$ssitrack->ssi_track_id = $regid;
$ssitrack->save();
$ssitrackk = Ssi_track::orderBy('ssi_track_id', 'desc')->get();
$ssitrackk = $ssitrackk[0]->registration_id;
}
}
});
return back()->with('success', 'Your File Is Successfully Uploaded To Database!');
}
return back()->with('success', 'File Doesnt Uploaded!');
}
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3z3Ne98
via IFTTT
Aucun commentaire:
Enregistrer un commentaire