Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -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
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down Expand Up @@ -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']);
});

...
Expand Down Expand Up @@ -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<br>Example: `User::allVersions()->get()` will return all versions of all users

* `moment(Carbon)` returns a specific version, closest but lower than the input date<br>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<br>Example: `User::moment(Carbon::now()->subWeek())->find(1)` will return the version at that point in time.

#### Create, update and delete records

Expand Down
1 change: 0 additions & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace ProAI\Versioning\Tests;

use Orchestra\Database\ConsoleServiceProvider;
use Orchestra\Testbench\TestCase as BaseTestCase;

class TestCase extends BaseTestCase
Expand Down