PHPackages                             ervinne/nw-cms-version - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. ervinne/nw-cms-version

ActiveLibrary[Database &amp; ORM](/categories/database)

ervinne/nw-cms-version
======================

Enables Laravel model version controlled fields.

v1.0.2(8y ago)039MITPHPPHP &gt;=5.6

Since Feb 13Pushed 8y ago1 watchersCompare

[ Source](https://github.com/ervinne13/nw-cms-versions)[ Packagist](https://packagist.org/packages/ervinne/nw-cms-version)[ RSS](/packages/ervinne-nw-cms-version/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependencies (2)Versions (6)Used By (0)

NuWorks CMS Model Version Control
=================================

[](#nuworks-cms-model-version-control)

This package enables tagging in Laravel models called versions. Versions allow different values at specified fields in a model.

Installation
------------

[](#installation)

Require the package in your composer.json and update your dependencies:

```
    $ composer require "ervinne/nw-cms-version:v1.0.0"

```

Then add the service provider in your `config/app.php` providers array:

```
    Ervinne\CMSVersion\Providers\CMSVersionServiceProvider::class,

```

Register Commands
-----------------

[](#register-commands)

To allow the command for generating migrations out of models to be version controlled, add the `GenerateCMSVersionMigrations` class to the `App\Console\Kernel` `$commands` property:

```
    /**
     * The Artisan commands provided by your application.
     *
     * @var array
     */
    protected $commands = [
        Ervinne\CMSVersion\Commands\GenerateCMSVersionMigrations::class
    ];
```

Configurations
--------------

[](#configurations)

You can set which models to `"Version Control"` on the `config/cms-versions.php` configuration file. Publish the config to create this configuration file. Note that you will need to publish as well to generate the required javascript files when you want to reflect version data on an already displaying form (more on that later):

```
    $ php artisan vendor:publish --provider="Ervinne\CMSVersion\Providers\CMSVersionServiceProvider"

```

Set which models you want to `version control` in the `config/cms-versions.php`

```
    'models' => [
        [
            'table'                => 'my_table',
            'primary_key'          => 'id',
            'classpath'            => \App\User::class,
            'is_published_field'   => 'my_is_published_field',
            'is_published_value'   => true,
            'is_unpublished_value' => false,
        ],
    ],
```

Where `table`, `primary_key`, `classpath` is the table, primary key, and class path of the model you want to version control. `is_published_field` is the name of the field you want to version control inside that model, ex: `is_published`, `is_active`, etc. `is_published_value` is the value that needs to be set to consider the field as "published", `is_unpublished_value` is vice versa.

In case you want to version control multiple fields in 1 model, just duplicate the model entries in the `models` array with the same `table`, `primary_key`, and `classpath`.

Migrating the Models
--------------------

[](#migrating-the-models)

To enable version control on the models, the user must `migrate` after configuration with the following command:

```
    $ php artisan make:cmsvmigration

```

This will create a migration called `create_cms_version_pivot_tables` that will contain database changes based on the configuration in `config/cms-versions.php`. Migrate afterwards using the command:

```
    $ php artisan migrate

```

Model Setup
-----------

[](#model-setup)

Use the trait `VersionControlled` in your model to enable versioning functionalities:

```
    ...
    use Ervinne\CMSVersion\VersionControlled;

    class BannerSet extends Model
    {
        use VersionControlled;
    ...
```

Saving Model to a Version
-------------------------

[](#saving-model-to-a-version)

Before you save a model, you need to save a version to save it to first:

```
    CMSVersion::insert([
        'display_name' => 'Default',
        'description' => 'Default Version',
        'status' => 'Published'
    ]);
```

Save your model by specifying the id of the saved `CMSVersion` object in the model's `version_id` field then save using the method `saveWithVersion()`.

```
    $bannerSet               = new BannerSet();
    $bannerSet->version_id   = $request->version_id; // assumes the version comes from the request
    $bannerSet->label        = $request->label;
    $bannerSet->images_json  = $request->banners;
    $bannerSet->is_published = $request->is_published;
    $bannerSet->saveWithVersion();
```

Version Status
--------------

[](#version-status)

Version `status` can be any string you want but `"Published"` is reserved and is set to signify that the version is the currently used version. If you try to save version controlled fields to a model set to a version that's not `published` then those changes wont save on the model itself but will be put in the version records only. If a version with model data is set to `published` it's data will be updated to the respective models.

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 80.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~56 days

Total

3

Last Release

2946d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4207769?v=4)[ervinne](/maintainers/ervinne)[@ervinne](https://github.com/ervinne)

---

Top Contributors

[![ervinne13](https://avatars.githubusercontent.com/u/5977614?v=4)](https://github.com/ervinne13 "ervinne13 (67 commits)")[![nw-ervinne](https://avatars.githubusercontent.com/u/57901581?v=4)](https://github.com/nw-ervinne "nw-ervinne (16 commits)")

---

Tags

laravelversion

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ervinne-nw-cms-version/health.svg)

```
[![Health](https://phpackages.com/badges/ervinne-nw-cms-version/health.svg)](https://phpackages.com/packages/ervinne-nw-cms-version)
```

###  Alternatives

[tpetry/laravel-postgresql-enhanced

Support for many missing PostgreSQL specific features

1.0k2.3M28](/packages/tpetry-laravel-postgresql-enhanced)[anourvalar/eloquent-serialize

Laravel Query Builder (Eloquent) serialization

11222.5M33](/packages/anourvalar-eloquent-serialize)[statamic-rad-pack/runway

Eloquently manage your database models in Statamic.

135212.4k7](/packages/statamic-rad-pack-runway)[waad/laravel-model-metadata

A robust Laravel package for handling metadata with JSON casting, custom relation names, and advanced querying capabilities.

854.1k](/packages/waad-laravel-model-metadata)[mozex/laravel-scout-bulk-actions

Import, flush, and queue-import all your Laravel Scout searchable models at once. Auto-discovers models, runs in bulk, tracks progress.

1437.7k](/packages/mozex-laravel-scout-bulk-actions)[ramadan/easy-model

A Laravel package for enjoyably managing database queries.

111.6k](/packages/ramadan-easy-model)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
