2017 © Pedro Peláez
 

library massdbimport

Import CSV files to database in Laravel

image

weblid/massdbimport

Import CSV files to database in Laravel

  • Thursday, June 29, 2017
  • by weblid
  • Repository
  • 0 Watchers
  • 0 Stars
  • 20 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 3 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Mass DB Import Interface

What is it?

Allows the easy upload of flat database files (currently only CSV) to be mapped to Eloquent models with simple relations., (*1)

How does it work?

Massdbimport::model('\App\Model')->source('db.csv')->import();

This will read the .csv file from the server and use the first row of columns as model attributes. It then skips through the values below and imports them to the database through the model., (*2)

Options

Relations

You can define relations in the CSV header with the 'relation:column' syntax. It will look in your model for the relation, and check the column of the related db table for the csv value (usually slug or id). Once found, it will create the relation on import., (*3)

You can define ManyToMany relationships by seperating your values with '|'., (*4)

Handling duplicates

You can define unique id columns (such as a slug) with the ->unique() interface like so:, (*5)

Massdbimport::model('\Weblid\Massdbimport\TestLocation')
->source('db.csv')
->unique('slug')
->ifDuplicate("SKIP")
->import();

You can also tell the importer what to do when it hits a duplicate with the ->ifDuplicate() interface. Options are:, (*6)

UPDATE SKIP RENAME, (*7)

Helper functions

Some functions have been made available that can be used in cells in the CSV file to manipulate or create custom cell data., (*8)

Slugify

slugify(column_name)

This will create a slug (no spaces, upper case) string from the given column name., (*9)

Imagify

imagify(url)

This will import an image or file from a given publically accessible url., (*10)

Current Status

Very early development., (*11)

The Versions

29/06 2017

dev-master

9999999-dev

Import CSV files to database in Laravel

  Sources   Download

The Requires

  • php >=5.5

 

by Barry Mason

29/06 2017

v1.0.2

1.0.2.0

Import CSV files to database in Laravel

  Sources   Download

The Requires

  • php >=5.5

 

by Barry Mason

29/06 2017

v1.0.1

1.0.1.0

Import CSV files to database in Laravel

  Sources   Download

The Requires

  • php >=5.5

 

by Barry Mason