Skip to content

Commit

Permalink
Merge pull request #6 from pmatseykanets/laravel6
Browse files Browse the repository at this point in the history
Support Laravel 6
  • Loading branch information
pmatseykanets authored Oct 26, 2019
2 parents 0ccca98 + a0b9349 commit 4e145e9
Show file tree
Hide file tree
Showing 17 changed files with 109 additions and 89 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
composer.lock
vendor
.idea
.DS_Store
Thumbs.db
.phpunit.result.cache
2 changes: 1 addition & 1 deletion .styleci.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
preset: recommended
preset: laravel
13 changes: 7 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
language: php

php:
- 5.5.9
- 5.5
- 5.6
- 7.0
- 7.1
- 7.2
- 7.3

env:
matrix:
Expand All @@ -17,4 +14,8 @@ before_script:
- travis_retry composer update ${COMPOSER_FLAGS} --no-interaction --prefer-source

script:
- vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover
- vendor/bin/phpunit

cache:
directories:
- $HOME/.composer/cache
18 changes: 17 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,45 @@
# Changelog

All notable changes to this project will be documented in this file.

## [2.0.0](https://github.com/pmatseykanets/artisan-io/releases/tag/v2.0.0) - 2019-10-25

### Changed

- Support Laravel 6

## [1.0.0](https://github.com/pmatseykanets/artisan-io/releases/tag/v1.0.0) - 2017-09-05

### Added

- Added a service provider and Laravel 5.5 package auto discovery.

## [Unreleased](https://github.com/pmatseykanets/artisan-io/tree/HEAD)

### Added

- Added CONTRIBUTING.md.
- Added LICENSE.md.
- Added CHANGELOG.md.
- Inculde php 7.0 and 7.1 into Travis-CI builds.
- Added .gitattributes.

### Updated

- Updated README.md.
- Updated dev dependencies.

## [0.2.0](https://github.com/pmatseykanets/artisan-io/releases/tag/v0.1.1) - 2015-09-22

### Added

- Added tests.
- Added Travis-CI config.

### Updated

- Updated README.md.

## [0.1.0](https://github.com/pmatseykanets/artisan-io/releases/tag/v0.1.0) - 2015-07-22
Initial release

Initial release.
27 changes: 12 additions & 15 deletions readme.md → README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
# artisan-io

[![Laravel 5.1](https://img.shields.io/badge/Laravel-5.1-orange.svg)](http://laravel.com)
[![StyleCI](https://styleci.io/repos/39307509/shield)](https://styleci.io/repos/39307509)
[![Build Status](https://travis-ci.org/pmatseykanets/artisan-io.svg)](https://travis-ci.org/pmatseykanets/artisan-io)
[![Latest Stable Version](https://poser.pugx.org/pmatseykanets/artisan-io/v/stable)](https://packagist.org/packages/pmatseykanets/artisan-io)
[![License](https://poser.pugx.org/pmatseykanets/artisan-io/license)](https://packagist.org/packages/pmatseykanets/artisan-io)

This package adds data import capability to your [Laravel 5](http://laravel.com/docs/5.1) project. It contains an artisan command `import:delimited` which allows you, as the name implies, to import delimited data (CSV, TSV, etc) into your local or remote database.
This package adds data import capability to your [Laravel](http://laravel.com/) project. It contains an artisan command `import:delimited` which allows you, as the name implies, to import delimited data (CSV, TSV, etc) into your local or remote database.

#### Main features:

- Supports multiple database connections (defined in [`config\database.php`](http://laravel.com/docs/5.1/database#introduction)).
- You can use either a table name or Eloquent model class to import your data. By using Eloquent model you can benefit from [mutators and accessors](http://laravel.com/docs/5.1/eloquent-mutators).
- Several import modes:
- Supports multiple database connections (defined in [`config\database.php`](http://laravel.com/docs/6.0/database#introduction)).
- You can use either a table name or Eloquent model class to import your data. By using Eloquent model you can benefit from [mutators and accessors](http://laravel.com/docs/6.0/eloquent-mutators).
- Import modes:
- insert
- insert-new
- update
- upsert
- Row validation rules


## Installation

You can install the package via composer:

```bash
$ composer require pmatseykanets/artisan-io
composer require pmatseykanets/artisan-io
```

If you're using Laravel < 5.5 or if you have package auto-discovery turned off you have to manually register the service provider:
Expand All @@ -50,8 +48,8 @@ protected $commands = [

## Usage

```
$ php artisan import:delimited --help
```bash
php artisan import:delimited --help

Usage:
import:delimited [options] [--] <from> <to>
Expand Down Expand Up @@ -129,7 +127,7 @@ class Employee extends Model
If `employees` table is empty and you'd like to populate it

```bash
$ php artisan import:delimited employee.csv "\App\Employee" -f email:0,firstname:1,lastname:2,phone:4,employed_on:3 -m insert
php artisan import:delimited employee.csv "\App\Employee" -f email:0,firstname:1,lastname:2,phone:4,employed_on:3 -m insert
```

Note: *The buity of using Eloquent model in this case is that timestamps `created_at` and `updated_at` will be populated by Eloquent automatically.*
Expand All @@ -139,15 +137,15 @@ Note: *The buity of using Eloquent model in this case is that timestamps `create
Now let's assume John's record is already present in the table. In order to update Jon's record and insert Jane's one you'd need to cnahge the mode and specify key field(s).
```bash
$ php artisan import:delimited employee.csv "\App\Employee" -f email:0,firstname:1,lastname:2,phone:4,employed_on:3 -m upsert -k email
php artisan import:delimited employee.csv "\App\Employee" -f email:0,firstname:1,lastname:2,phone:4,employed_on:3 -m upsert -k email
```
#### Update
If you want to just update phone numbers for existing records
```bash
$ php artisan import:delimited employee.csv "\App\Employee" -f email:0,phone:4 -m update -k email
php artisan import:delimited employee.csv "\App\Employee" -f email:0,phone:4 -m update -k email
```
### Field definition file
Expand All @@ -170,7 +168,7 @@ employed_on:3
### Row validation rules file
A row validation rule file is simply a php file that returns an array of rules. You can any of the [available Laravel validation rules](http://laravel.com/docs/5.1/validation#available-validation-rules)
A row validation rule file is simply a php file that returns an array of rules. You can any of the [available Laravel validation rules](http://laravel.com/docs/6.0/validation#available-validation-rules)
#### Example `employee.rule`
Expand All @@ -186,7 +184,6 @@ return [
];
```

### License
## License
The artisan-io is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)
21 changes: 10 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,21 @@
{
"name": "Peter Matseykanets",
"email": "pmatseykanets@gmail.com",
"homepage": "https://github.com/pmatseykanets",
"role": "Developer"
"homepage": "https://github.com/pmatseykanets"
}
],
"require": {
"php": ">=5.5.9",
"illuminate/support": "~5.1",
"illuminate/container": "~5.1",
"illuminate/database": "~5.1",
"illuminate/validation": "~5.1",
"illuminate/config": "~5.1",
"illuminate/console": "~5.1"
"php": "^7.2",
"illuminate/support": "~5.1|~6.0",
"illuminate/container": "~5.1|~6.0",
"illuminate/database": "~5.1|~6.0",
"illuminate/validation": "~5.1|~6.0",
"illuminate/config": "~5.1|~6.0",
"illuminate/console": "~5.1|~6.0"
},
"require-dev": {
"phpunit/phpunit": "^4.8",
"mockery/mockery": "^0.9.5"
"phpunit/phpunit": "^8.0",
"mockery/mockery": "^1.0"
},
"autoload": {
"psr-4": {
Expand Down
1 change: 0 additions & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
>
<testsuites>
<testsuite name="ArtisanIo Test Suite">
Expand Down
2 changes: 1 addition & 1 deletion src/ArtisanIoServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace ArtisanIo;

use ArtisanIo\Console\ImportDelimitedCommand;
use Illuminate\Support\ServiceProvider;
use ArtisanIo\Console\ImportDelimitedCommand;

class ArtisanIoServiceProvider extends ServiceProvider
{
Expand Down
12 changes: 6 additions & 6 deletions src/Console/ImportDelimitedCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

namespace ArtisanIo\Console;

use Illuminate\Support\Str;
use Illuminate\Console\Command;
use ArtisanIo\Delimited\BaseImport;
use ArtisanIo\Delimited\ModelImport;
use ArtisanIo\Delimited\TableImport;
use Illuminate\Console\Command;
use Illuminate\Console\ConfirmableTrait;
use Illuminate\Support\Str;

class ImportDelimitedCommand extends Command
{
Expand Down Expand Up @@ -55,7 +55,7 @@ class ImportDelimitedCommand extends Command
*/
public function handle()
{
if (!$this->confirmToProceed()) {
if (! $this->confirmToProceed()) {
return;
}

Expand Down Expand Up @@ -151,15 +151,15 @@ protected function parseArguments()
}

// Are we going to display the progress bar?
$this->showProgress = !$this->option('no-progress');
$this->showProgress = ! $this->option('no-progress');
}

/**
* Displays the number of imported records.
*/
protected function reportImported()
{
if (!$this->import) {
if (! $this->import) {
return;
}

Expand All @@ -185,7 +185,7 @@ protected function abort($message, $code = 1)
$this->progressRemove();
}

if (!is_null($this->import)) {
if (! is_null($this->import)) {
$this->reportImported();

if ($lastLine = $this->import->getCurrentFileLine()) {
Expand Down
Loading

0 comments on commit 4e145e9

Please sign in to comment.