PHPackages                             cape-and-bay/versionable - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. cape-and-bay/versionable

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

cape-and-bay/versionable
========================

Laravel Drafts tool for models

v1.0.1(3y ago)02.5kMITPHPPHP ^8.1

Since Jan 18Pushed 3y agoCompare

[ Source](https://github.com/GymRevenue/versionable)[ Packagist](https://packagist.org/packages/cape-and-bay/versionable)[ Docs](https://github.com/GymRevenue/versionable)[ RSS](/packages/cape-and-bay-versionable/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (2)Versions (3)Used By (0)

 versionable
=============

[](#-versionable-)

 ⏱️ Make Laravel model versionable.

It's a minimalist way to make your model support version history, and it's very simple to roll back to the specified version.

Requirement
-----------

[](#requirement)

1. PHP &gt;= 8.1
2. laravel/framework &gt;= 9.0

Installing
----------

[](#installing)

```
composer require cape-and-bay/versionable -vvv
```

Then run this command to create a database migration:

```
php artisan migrate
```

Usage
-----

[](#usage)

Add `CapeAndBay\Versionable\Versionable` trait to the model that you want to be versioned:

```
use CapeAndBay\Versionable\Versionable;

class Post extends Model
{
    use Versionable;

    # Prevents versioning Post if only the "is_active" column is updated.
    protected array $dont_version = ['is_active'];
}
```

Versions will be created on vensionable model saved.

```
$post = Post::create(['title' => 'version1', 'content' => 'version1 content']);
$post->update(['title' => 'version2']);
```

You can prevent a new version of model from being created by return `false` on `onNewVersionCreate`. to use this method, your model must implement the `VersionableInterface` in conjunction with `Versionable` trait:

```
use CapeAndBay\Versionable\Versionable;
use CapeAndBay\Versionable\VersionableInterface;
use Illuminate\Database\Eloquent\Model;

class User extends Model implements VersionableInterface
{
    use Versionable;

    public function onNewVersionCreate(Model $model) : bool
    {
        // Create new version if email is not "skip@mail.com"
        return $model->email !== 'skip@mail.com';
    }
}
```

### Get versions

[](#get-versions)

```
$post->versions; // all versions
$post->latestVersion(); // latest version
$post->versions->first(); // first version
```

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~0 days

Total

2

Last Release

1263d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4efbf94b35bb601103d3f8343cadc4656414ae5ae396410d7d444d56f580e571?d=identicon)[cnb](/maintainers/cnb)

---

Top Contributors

[![chrys-u](https://avatars.githubusercontent.com/u/112005953?v=4)](https://github.com/chrys-u "chrys-u (3 commits)")

---

Tags

versionablecapeandbay

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/cape-and-bay-versionable/health.svg)

```
[![Health](https://phpackages.com/badges/cape-and-bay-versionable/health.svg)](https://phpackages.com/packages/cape-and-bay-versionable)
```

###  Alternatives

[lummy/laravel-vue-api-crud-generator

Creates a basic skeleton for a CRUD app in both Laravel &amp; Vue.js single file components.

163.0k](/packages/lummy-laravel-vue-api-crud-generator)

PHPackages © 2026

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