New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

sukohi/back-then

A Laravel package for managing reivision of database.
14

Larablocks Analysis

sukohi/back-then works with Laravel 5 (latest release 1.0.3, May 23, 2017), which reached end of life: no more fixes, even for security.

Recommendation checks

Not advised

Not advised: no release or commit in over 2 years.

  • No release or commit in over 2 years
  • Supports only Laravel 5, past end of life
  • No release in the last 12 months (last: May 23, 2017)
  • 0 downloads a month (needs 10,000)
  • 0 GitHub stars (needs 100)

State

Likely abandoned
  • No release or commit in over 2 years.
  • Last stable release: May 23, 2017.
  • No releases in the last 12 months.
  • First released: May 23, 2017.
  • 0 open issues on GitHub.

Data from Packagist and GitHub, checked by Larablocks on Nov 26, 2026.

Install
composer require sukohi/back-then
Latest Version:1.0.3
Laravel:5
License:MIT
Last Updated:May 23, 2017
Links: GitHub  ·  Packagist
Maintainer: Sukohi

BackThen

A Laravel package for managing reivision of database. (This package is for Laravel 5+)

Installation

Execute the following composer command.

composer require sukohi/back-then:1.*

then set BackThenServiceProvider in your config/app.php.

Sukohi\BackThen\BackThenServiceProvider::class, 

Preparation

To make a table for this package, execute the following commands.

php artisan vendor:publish --provider="Sukohi\BackThen\BackThenServiceProvider"

and

php artisan migrate

Add BackThenTrait to your model like so.

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Sukohi\BackThen\BackThenTrait;

class Product extends Model
{
    use BackThenTrait;

That's all.
Now when you create, update or delete record, this package automatically will save revision record(s).

Usage

You can save and delete record as usual like so.

$product = new \App\Product();
$product->name = 'xxxxxxx';
$product->save();   // Revision record will be saved.

$product = \App\Product::find(1);
$product->name = 'yyyyyyy';
$product->save();   // Revision record will be saved.

$product->delete();   // Revision record will be saved.

Save user ID

You can save ID of user who saved/deleted through revision_user_id.

$product = \App\Product::find(1);
$product->revision_user_id = 1; // User ID you want to save.
$product->save();

Retrieve Current Revision ID and Unique ID

echo $product->revision_id;
echo $product->revision_unique_id;
  • You can change revision you want via revision ID or unique ID.

Change Revision

via changeRevisionById

$revision_id = 1;

if($product->hasRevisionId($revision_id)) {

    $product->changeRevisionById($revision_id); // This has old values.

}

or via changeRevision

$unique_id = '5a906ea1934196bc065f1b22eafd90c9';

if($product->hasRevisionUniqueId($unique_id)) {

    $product->changeRevision($unique_id); // This has old values.

}

Note: Once you call changeRevisionById() or changeRevision(), the model has old values.
This means if you save it, of cause, the latest value will be replaced with the old ones.
So don't forget to call clearRevision() if you need to save at the same time.

Return to the Latest Revision

$product->clearRevision();

Revision Columns

If you'd like this package to save specific revision record.
Set column names in your model like so.

protected $revisions = ['column_name'];

or

protected $ignore_revisions = ['column_name'];

Retrieve Revision data

$histories = $product->revisionHistory; // All revisions

or

$revision = $product->getRevisionById(1);   // A specific revision
$revision = $product->getRevision('5a906ea1934196bc065f1b22eafd90c9');// A specific revision

License

This package is licensed under the MIT License.

Copyright 2017 Sukohi Kuhoh

Related Packages

doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

670,032,257 9,703
laravel/framework

The Laravel Framework.

640,572,096 35,338
laravel/tinker

Powerful REPL for the Laravel framework.

546,909,908 7,440
laravel/serializable-closure

Laravel Serializable Closure provides an easy and secure way to serialize closur...

465,816,364 607
nunomaduro/collision

Cli error handling for console/command-line PHP applications.

431,187,642 4,660

Version History

Version Released Laravel License
1.0.3 ~5.0 MIT
1.0.2 ~5.0 MIT
1.0.1 ~5.0 MIT
1.0.0 ~5.0 MIT