diff --git a/.scrutinizer.yml b/.scrutinizer.yml new file mode 100644 index 0000000..5e16797 --- /dev/null +++ b/.scrutinizer.yml @@ -0,0 +1,35 @@ +checks: + php: + code_rating: true + duplication: true + +filter: + excluded_paths: + - tests/* + +build: + nodes: + php71: + environment: + php: + version: 7.1.12 + tests: + override: + - php-scrutinizer-run + - + command: vendor/bin/phpunit --coverage-clover=coverage71 + coverage: + file: coverage71 + format: php-clover + php72: + environment: + php: + version: 7.2.0 + tests: + override: + - php-scrutinizer-run + - + command: vendor/bin/phpunit --coverage-clover=coverage72 + coverage: + file: coverage72 + format: php-clover \ No newline at end of file diff --git a/README.md b/README.md index 405078d..f7c7ea7 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Eloquent Versioning -[![Latest Stable Version](https://poser.pugx.org/proai/eloquent-versioning/v/stable)](https://packagist.org/packages/proai/eloquent-versioning) [![Total Downloads](https://poser.pugx.org/proai/eloquent-versioning/downloads)](https://packagist.org/packages/proai/eloquent-versioning) [![Latest Unstable Version](https://poser.pugx.org/proai/eloquent-versioning/v/unstable)](https://packagist.org/packages/proai/eloquent-versioning) [![License](https://poser.pugx.org/proai/eloquent-versioning/license)](https://packagist.org/packages/proai/eloquent-versioning) +[![Build status](https://scrutinizer-ci.com/g/ProAI/eloquent-versioning/badges/build.png?b=master)](https://scrutinizer-ci.com/g/ProAI/eloquent-versioning/) [![Quality score](https://scrutinizer-ci.com/g/ProAI/eloquent-versioning/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/ProAI/eloquent-versioning/) [![Latest Stable Version](https://poser.pugx.org/proai/eloquent-versioning/v/stable)](https://packagist.org/packages/proai/eloquent-versioning) [![Total Downloads](https://poser.pugx.org/proai/eloquent-versioning/downloads)](https://packagist.org/packages/proai/eloquent-versioning) [![Latest Unstable Version](https://poser.pugx.org/proai/eloquent-versioning/v/unstable)](https://packagist.org/packages/proai/eloquent-versioning) [![License](https://poser.pugx.org/proai/eloquent-versioning/license)](https://packagist.org/packages/proai/eloquent-versioning) This is an extension for the Eloquent ORM to support versioning. You can specify attributes as versioned. If an attribute is specified as versioned the value will be saved in a separate version table on each update. It is possible to use timestamps and soft deletes with this feature. @@ -29,12 +29,14 @@ Schema::create('users', function(Blueprint $table) { }); Schema::create('users_version', function(Blueprint $table) { - $table->integer('ref_id')->primary(); - $table->integer('version')->primary(); + $table->integer('ref_id')->unsigned(); + $table->integer('version')->unsigned(); $table->string('email'); $table->string('city'); $table->timestamp('updated_at'); $table->timestamp('deleted_at'); + + $table->primary(['ref_id', 'version']); }); ... @@ -90,7 +92,7 @@ By default the query builder will fetch the latest version (e. g. `User::find(1) * `allVersions()` returns all versions of the queried items
Example: `User::allVersions()->get()` will return all versions of all users -* `moment(Carbon)` returns a specific version, closest but lower than the input date
Example: `User::moment(Carbon::now()->subWeek()->find(1)` will return the version at that point in time. +* `moment(Carbon)` returns a specific version, closest but lower than the input date
Example: `User::moment(Carbon::now()->subWeek())->find(1)` will return the version at that point in time. #### Create, update and delete records diff --git a/tests/TestCase.php b/tests/TestCase.php index f89c0dc..d1ee87c 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -2,7 +2,6 @@ namespace ProAI\Versioning\Tests; -use Orchestra\Database\ConsoleServiceProvider; use Orchestra\Testbench\TestCase as BaseTestCase; class TestCase extends BaseTestCase