Senior Software Developer

Laravel Csv to Model

A plugin adding the ability to directly import csv data to an eloquent model.

Laravel Csv to Model

I have found myself in situations where I have needed to import csv/excel files and create records within a laravel application.

This can sometimes be tedious task and having to repeat this functionality across multiple projects has made me think that having a package to do all this would be truly helpful.

I have created Laravel Csv To Model, a package which provides functionality to a model class to directly import data into it's table.

It works be importing and using the CsvToModel trait in the model you would like to import to:

use Kakposoe\CsvToModel\Traits\CsvToModel;

class YourModel extends Model
    use CsvToModel;


Once done, the model can now import csv files directly into the model's database:

$csv = YourMode::csv($filePath);


There are options to define headers, format row data before saving and only import specifid fields.