samedi 31 octobre 2015

error in getting results from Excel file in Laravel 5.1

I am trying to retrieve results from an excel file to save the results in the database column. Here is what I am trying

public function addRecords(Request $request){
        $file = $request->get('file');
        //echo $file;
        Excel::load($file, function($reader){
            $results = $reader->get()->toArray();

            echo $results;
            foreach($results as $key => $value){
                $sim = new Sim();
                $sim->msisdn = $value['msisdn'];
                $sim->imei = $value['imei'];
                $sim->issued_to = $value['issued_to'];
                $sim->associated_with_employee = $value['associated_with_employee'];

                $sim->save();
            }
        });
    }

I am getting error Undefined index: msisdn|imei|issued_to|associated_with_employee. What I am doing wrong here?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire