Learn how to import data from csv using Eloquent in Laravel

When working with data, there are many different sources and file types that we may encounter. A common type is a CSV, or comma separated value, file. In this recipe, we’ll take a CSV file’s contents and insert them into our database.

About the author

Deven Rathore

I'm Deven Rathore, a multidisciplinary & self-taught designer with 3 years of experience. I'm passionate about technology, music, coffee, traveling and everything visually stimulating. Constantly learning and experiencing new things.

  • FatalErrorException in routes.php line 14:Class ‘Scifi’ not found

    • Deven Rathore

      make sure you have ran this comand

      php artisan make:migration create_scifi_table

  • Philip Ryan

    Cool, thanks for this. I was looking for was a working example. I had to deal with lack of timestamps in the table I was importing into (put `public $timestamps = false;` into the model file for that object), and then had to deal with various date formats, so PHP’s DateTime::createFromFormat() were used to good effect.

Pin It on Pinterest

Shares