stef
480
1
Laravel

Laravel Excel create table and insert data

Posted 3 years ago by stef

Hi @all,

i am using this Laravel plugin http://www.maatwebsite.nl/laravel-excel/docs/import to insert data into a database.

How can i check if a table exists and if not how to create?

Excel::load(Input::file('file'), function ($reader) {
     $reader->each(function($sheet) {    
         foreach ($sheet->toArray() as $row) {
            User::firstOrCreate($row);
         }
     });
});

Thx again

Please sign in or create an account to participate in this conversation.