2017 © Pedro Peláez
 

project import

A simle package to assist with importing data via csv.

image

jameron/import

A simle package to assist with importing data via csv.

  • Friday, January 26, 2018
  • by Jameron
  • Repository
  • 1 Watchers
  • 0 Stars
  • 55 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 42 Versions
  • 0 % Grown

The README.md

This package has been built to work with Laravel 5.4.33 and later., (*1)

This package contains methods and traits that can be used with your project, and optionally you can use the views or just the view parials for your UX. If you are using the upload view, make sure you also require the admin package found here: Admin package, (*2)

Your composer file would look like so:, (*3)

        "jameron/admin": "*",
        "jameron/import": "*",

Some older versions may not be compatible. Let's see if we can't get you up and running in 10 steps. If you are starting fresh, create your laravel application first thing:, (*4)

    composer create-project --prefer-dist laravel/laravel blog

1) Add the package to your compose.json file:, (*5)

    "jameron/import": "*",
composer update

**NOTE Laravel 5.5+ users there is auto-discovery so you can ignore steps 2 and 3, (*6)

2) Update your providers:, (*7)

        Jameron\Regulator\ImportsServiceProvider::class,

3) Update your Facades:, (*8)

        'Imports' => Jameron\Regulator\Facades\ImportsFacade::class,

4) Publish the views and config:, (*9)


php artisan vendor:publish

5) (Only if using Regulator for roles and permissions) Seed the database with import permission and assign permission to admin role, (*10)

You can call it directly via command line or add it to your applications seeder file:, (*11)

Added to application seeder, (*12)

database/seeds/DatabaseSeeder.php, (*13)

$this->call(\Jameron\Import\database\seeds\ImportSeeder::class);

Called via command line:, (*14)

php artisan db:seed --class=\\Jameron\\Import\\database\\seeds\\ImportSeeder

6) Update your webpack.mix.js file, (*15)

   .js('resources/assets/import/js/upload.js', 'public/js/Upload.js')
   .sass('resources/assets/import/sass/upload.scss', 'public/css')

7) Compile it up:, (*16)

npm run dev

8) Setup your routes and controllers, (*17)


Route::group(['middleware' => ['web', 'auth', 'role:admin']], function () { Route::get('/import', 'ImportController@getImport'); Route::post('/import', 'ImportController@postImport'); });

use \Jameron\Import\Http\Requests\ImportRequest; class ImportController extends Controller { public function getImport() { return view('import::upload'); } public function postImport(ImportRequest $request) { $csv = $request->file('csv'); $headers_cleanup_rules = ['trim','pound_to_word_number','spaces_to_underscores', 'remove_special_characters','lowercase']; $import_model = \App\Models\QuizScores::class; $validator = \App\Http\Requests\QuizScoreRequest::class; $relationships = [ [ 'create_if_not_found' => true, 'csv_column' => 'student_id', 'reference_table' => 'users', 'reference_field' => 'student_identification_number', 'reference_primary_key' => 'id', 'foreign_key' => 'student_id', 'relationship' => 'belongsTo', 'model' => \App\Models\User::class, 'validator' => \App\Http\Requests\UserRequest::class, 'roles' => ['student'], // this only works for new users with the regulator package installed 'extra_columns' => [ [ 'column' => 'student_name', 'maps_to' => ['first_name','last_name'], 'explode_on' => ' ' ], [ 'column' => 'email', 'maps_to' => 'email', ] ], 'append_data' => [ 'password' => \Hash::make('ChangeIt!') ] ], [ 'csv_column' => 'test_name', 'reference_table' => 'tests', 'reference_field' => 'name', // This assumes that the name field on the tests table has a rule that forces unique 'reference_primary_key' => 'id', 'foreign_key' => 'test_id', 'model' => \App\Models\Tests::class, 'validator' => \App\Http\Requests\TestRequest::class, ] ]; } }

The Versions

26/01 2018

dev-master

9999999-dev http://cjmacfarlane.com

A simle package to assist with importing data via csv.

  Sources   Download

MIT

by Cameron Macfarlane

csv import

26/01 2018

1.4.1

1.4.1.0 http://cjmacfarlane.com

A simle package to assist with importing data via csv.

  Sources   Download

MIT

by Cameron Macfarlane

csv import

24/01 2018

1.4.0

1.4.0.0 http://cjmacfarlane.com

A simle package to assist with importing data via csv.

  Sources   Download

MIT

by Cameron Macfarlane

csv import

24/01 2018

1.3.9

1.3.9.0 http://cjmacfarlane.com

A simle package to assist with importing data via csv.

  Sources   Download

MIT

by Cameron Macfarlane

csv import

24/01 2018

1.3.8

1.3.8.0 http://cjmacfarlane.com

A simle package to assist with importing data via csv.

  Sources   Download

MIT

by Cameron Macfarlane

csv import

23/01 2018

1.3.7

1.3.7.0 http://cjmacfarlane.com

A simle package to assist with importing data via csv.

  Sources   Download

MIT

by Cameron Macfarlane

csv import

23/01 2018

1.3.6

1.3.6.0 http://cjmacfarlane.com

A simle package to assist with importing data via csv.

  Sources   Download

MIT

by Cameron Macfarlane

csv import

19/01 2018

1.3.5

1.3.5.0 http://cjmacfarlane.com

A simle package to assist with importing data via csv.

  Sources   Download

MIT

by Cameron Macfarlane

csv import

19/01 2018

1.3.4

1.3.4.0 http://cjmacfarlane.com

A simle package to assist with importing data via csv.

  Sources   Download

MIT

by Cameron Macfarlane

csv import

19/01 2018

1.3.3

1.3.3.0 http://cjmacfarlane.com

A simle package to assist with importing data via csv.

  Sources   Download

MIT

by Cameron Macfarlane

csv import

18/01 2018

1.3.2

1.3.2.0 http://cjmacfarlane.com

A simle package to assist with importing data via csv.

  Sources   Download

MIT

by Cameron Macfarlane

csv import

11/01 2018

1.3.1

1.3.1.0 http://cjmacfarlane.com

A simle package to assist with importing data via csv.

  Sources   Download

MIT

by Cameron Macfarlane

csv import

11/01 2018

1.3.0

1.3.0.0 http://cjmacfarlane.com

A simle package to assist with importing data via csv.

  Sources   Download

MIT

by Cameron Macfarlane

csv import

11/01 2018

1.2.9

1.2.9.0 http://cjmacfarlane.com

A simle package to assist with importing data via csv.

  Sources   Download

MIT

by Cameron Macfarlane

csv import

10/01 2018

1.2.8

1.2.8.0 http://cjmacfarlane.com

A simle package to assist with importing data via csv.

  Sources   Download

MIT

by Cameron Macfarlane

csv import

10/01 2018

1.2.7

1.2.7.0 http://cjmacfarlane.com

A simle package to assist with importing data via csv.

  Sources   Download

MIT

by Cameron Macfarlane

csv import

09/01 2018

1.2.6

1.2.6.0 http://cjmacfarlane.com

A simle package to assist with importing data via csv.

  Sources   Download

MIT

by Cameron Macfarlane

csv import

06/01 2018

1.2.5

1.2.5.0 http://cjmacfarlane.com

A simle package to assist with importing data via csv.

  Sources   Download

MIT

by Cameron Macfarlane

csv import

06/01 2018

1.2.4

1.2.4.0 http://cjmacfarlane.com

A simle package to assist with importing data via csv.

  Sources   Download

MIT

by Cameron Macfarlane

csv import

06/01 2018

1.2.3

1.2.3.0 http://cjmacfarlane.com

A simle package to assist with importing data via csv.

  Sources   Download

MIT

by Cameron Macfarlane

csv import

05/01 2018

1.2.2

1.2.2.0 http://cjmacfarlane.com

A simle package to assist with importing data via csv.

  Sources   Download

MIT

by Cameron Macfarlane

csv import

05/01 2018

1.2.1

1.2.1.0 http://cjmacfarlane.com

A simle package to assist with importing data via csv.

  Sources   Download

MIT

by Cameron Macfarlane

csv import

04/01 2018

1.2.0

1.2.0.0 http://cjmacfarlane.com

A simle package to assist with importing data via csv.

  Sources   Download

MIT

by Cameron Macfarlane

csv import

04/01 2018

1.1.9

1.1.9.0 http://cjmacfarlane.com

A simle package to assist with importing data via csv.

  Sources   Download

MIT

by Cameron Macfarlane

csv import

04/01 2018

1.1.8

1.1.8.0 http://cjmacfarlane.com

A simle package to assist with importing data via csv.

  Sources   Download

MIT

by Cameron Macfarlane

csv import

03/01 2018

1.1.7

1.1.7.0 http://cjmacfarlane.com

A simle package to assist with importing data via csv.

  Sources   Download

MIT

by Cameron Macfarlane

csv import

03/01 2018

1.1.6

1.1.6.0 http://cjmacfarlane.com

A simle package to assist with importing data via csv.

  Sources   Download

MIT

by Cameron Macfarlane

csv import

30/12 2017

1.1.5

1.1.5.0 http://cjmacfarlane.com

A simle package to assist with importing data via csv.

  Sources   Download

MIT

by Cameron Macfarlane

csv import

30/12 2017

1.1.4

1.1.4.0 http://cjmacfarlane.com

A simle package to assist with importing data via csv.

  Sources   Download

MIT

by Cameron Macfarlane

csv import

30/12 2017

1.1.2

1.1.2.0 http://cjmacfarlane.com

A simle package to assist with importing data via csv.

  Sources   Download

MIT

by Cameron Macfarlane

csv import

29/12 2017

1.1.1

1.1.1.0 http://cjmacfarlane.com

A simle package to assist with importing data via csv.

  Sources   Download

MIT

by Cameron Macfarlane

csv import

29/12 2017

1.1.0

1.1.0.0 http://cjmacfarlane.com

A simle package to assist with importing data via csv.

  Sources   Download

MIT

by Cameron Macfarlane

csv import

29/12 2017

1.0.9

1.0.9.0 http://cjmacfarlane.com

A simle package to assist with importing data via csv.

  Sources   Download

MIT

by Cameron Macfarlane

csv import

29/12 2017

1.0.8

1.0.8.0 http://cjmacfarlane.com

A simle package to assist with importing data via csv.

  Sources   Download

MIT

by Cameron Macfarlane

csv import

29/12 2017

1.0.7

1.0.7.0 http://cjmacfarlane.com

A simle package to assist with importing data via csv.

  Sources   Download

MIT

by Cameron Macfarlane

csv import

29/12 2017

1.0.6

1.0.6.0 http://cjmacfarlane.com

A simle package to assist with importing data via csv.

  Sources   Download

MIT

by Cameron Macfarlane

csv import

29/12 2017

1.0.5

1.0.5.0 http://cjmacfarlane.com

A simle package to assist with importing data via csv.

  Sources   Download

MIT

by Cameron Macfarlane

csv import

29/12 2017

1.0.4

1.0.4.0 http://cjmacfarlane.com

A simle package to assist with importing data via csv.

  Sources   Download

MIT

by Cameron Macfarlane

csv import

29/12 2017

1.0.3

1.0.3.0 http://cjmacfarlane.com

A simle package to assist with importing data via csv.

  Sources   Download

MIT

by Cameron Macfarlane

csv import

29/12 2017

1.0.2

1.0.2.0 http://cjmacfarlane.com

A simle package to assist with importing data via csv.

  Sources   Download

MIT

by Cameron Macfarlane

csv import

28/12 2017

1.0.1

1.0.1.0 http://cjmacfarlane.com

A simle package to assist with importing data via csv.

  Sources   Download

MIT

by Cameron Macfarlane

csv import

28/12 2017

1.0.0

1.0.0.0 http://cjmacfarlane.com

A simle package to assist with importing data via csv.

  Sources   Download

MIT

by Cameron Macfarlane

csv import