jeudi 24 mars 2016

using maatweb excel packaage how to import excel sheet into differeny mysql tables

I have this import function

 public function import()
        {
           $file=Input::file("file");
            Excel::load($file, function($reader)
            {
                $results = $reader->get();
                foreach($results as $row):
                   MR::create([
                        'mr_no'     =>$row->mr_no,
                        'mr_subject'=>$row->mr_subject,
                        'mr_date' =>date("d-M-Y g:i A",strtotime($row->mr_date)),
          ]);
                endforeach;
            });
            return redirect ('mrs');
        }

The above code import the excel sheet into one table mrs , i neeed also to import to another table of name materials
using the same excel sheet
i've created a model of name Material in laravel and a database pivot table of name material_mr
how can import the data in excel sheet into two different tables?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire