Download the PHP package nexuspoint/laravel-versioned without Composer

On this page you can find all versions of the php package nexuspoint/laravel-versioned. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-versioned

Laravel Versioned

A Laravel 5 package to handle versioning on any of your Eloquent models.

Example Usage

$post = new App\Post();
$post->title = 'Some title';
$post->body = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit.';
$post->save();

echo $post->getCurrentVersion(); // 1

The post is saved. There are no previous versions.

Now we can update the post.

$post->body = 'New body text';
$post->save();

echo $post->getCurrentVersion(); // 2

We've automatically versioned it.

$post->body = 'Even newer body text';
$post->save();

echo $post->getCurrentVersion(); // 3

And again.

$post->restoreVersion(1); // true

echo $post->getCurrentVersion(); // 4

$post->toArray();

[
     "title" => "Some title",
     "body" => "Lorem ipsum dolor sit amet, consectetur adipisicing elit.",
     "updated_at" => "2015-09-15 19:43:45",
     "created_at" => "2015-09-15 19:41:17",
     "id" => 1,
]

Now we've restored the data as it was at version 1, but as a new version.

$post->rollback();

echo $post->getCurrentVersion(); // 3

$post->toArray();

[
     "title" => "Some title",
     "body" => "Even newer body text",
     "updated_at" => "2015-09-15 19:43:45",
     "created_at" => "2015-09-15 19:41:17",
     "id" => 1,
]

Rollback is effectively an 'undo' on the model. It also removes the history so we're back at version 3.

Installation

Install with Composer:

composer require nexuspoint/versioned

Then create the following migration:

<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateVersionsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('versions', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('version_no')->unsigned();
            $table->integer('subject_id')->unsigned();
            $table->string('subject_class');
            $table->string('name');
            $table->text('data');
            $table->string('hash');
            $table->timestamps();
        });

    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('versions');
    }
}

run migrations

php artisan migrate

Add the trait to your Eloquent class, and set $versionNameColumn to the field that you want to record as the version name column.

<?php
use Illuminate\Database\Eloquent\Model;
use NexusPoint\Versioned\Versioned;

class Post extends Model
{
    use Versioned;

    /**
     * Field from the model to use as the versions name
     * @var string
     */
    protected $versionNameColumn = 'title';
}

Other methods

Manually add a new version of the model in its current state. I recommend to save the model after this. Normally you wouldn't need to call this manualy as the model will automatically version every time it is changed.

$post->addVersion('optional version name');

Get all versions for display in UI to select a version

$post->getAllVersions();

Get a specific version. This method will return the correct model so that any get mutators or methods are useable and you can display a previous version in your UI.

$post->getVersion({version number});

Get current version number.

$post->getCurrentVersionNumber();

Get previous version for display in UI.

$post->getPreviousVersion();

Restore to a previous version. All versions after the given version number will be conserved, and the current version will also be saved so that you can later undo.

$post->restoreVersion({version number});

Similar to restore version, this deletes all the history after the given version so really is like going back in time.

$post->rollbackToVersion({version number});

Rollback to the last version. This is effectively an 'undo' function to remove the latest version.

$post->rollback();

Delete a given version.

$post->deleteVersion({version number});

Delete all version history of a model.

$post->deleteAllVersions();

Upcoming Features

I'd like to integrate a javascript diff engine to this package so that users can immediately see what has changed between versions.

I'll be adding some tests soon.

Contributing

Pull requests welcome for bug fixes, and new useful features.


All versions of laravel-versioned with dependencies

PHP Build Version
Package Version
Requires php Version >=5.5.9
illuminate/database Version 5.*
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package nexuspoint/laravel-versioned contains the following files

Loading the files please wait ....