laravel - Laravel5.3 maatwebsite/excel Read value from excel & insert into database -


here excel data sheet type:

enter image description here

here table schema:

enter image description here

here method import data:

public function saveactivationinfoexcel(request $request)     {          if($request->hasfile('import_file')){             $path = $request->file('import_file')->getrealpath();              $data = excel::load($path, function($reader) {})->get();              if(!empty($data) && $data->count()){                  foreach ($data->toarray() $key => $value) {                     if(!empty($value)){                         foreach ($value $v) {                                     $insert[] = [                                         'mobile_no' =>$v['mobile_no'],                                          'model' => $v['model'],                                         'serial_1' => $v['serial_1'],                                         'serial_2' => $v['serial_2'],                                         'activation_date' => $v['activation_date'],                                         ];                         }                     }                 }                  dd($insert);                 if(!empty($insert)){                     //productactivationinfo::insert($insert);                     return back()->with('success','insert record successfully.');                 }              }          }          return back()->with('error','please check file, wrong there.');     } 

now problem is, when try import data got dd($insert) error

illegal string offset 'mobile_no'  'serial_1' => '3.5194508009307e+14',  'serial_2' => '3.5194508009307e+14',  'activation_date' => object(carbon), null) 

have both serial_1 & serial_2 showing different value rather actual excel value. activation_date value null.

would appreciate valuable suggestion solve regarding reading data using "maatwebsite/excel" laravel library.


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -