588 GitHub stars and counting — overtrue/laravel-versionable is a PHP project TopGit is tracking across repositories on the platform. ⏱️Make Laravel model versionable
Snapshot summary built from the project's own GitHub metadata — there's no written TopGit review yet. The page will update automatically when a full review is published.
WHY NO REVIEW YET
TopGit writes full reviews for the most-starred, most-requested repositories. This page is a snapshot until then — see the READ ME tab for the original README in full.
Then run this command to create a database migration:
php artisan migrate
Usage
Add Overtrue\LaravelVersionable\Versionable trait to the model and set versionable attributes:
use Overtrue\LaravelVersionable\Versionable;
class Post extends Model
{
use Versionable;
/**
* Versionable attributes
*
* @var array
*/
protected $versionable = ['title', 'content'];
// Or use a blacklist
//protected $dontVersionable = ['created_at', 'updated_at'];
<...>
}
Versions will be created on the vensionable model saved.
$post->versions; // all versions
$post->latestVersion; // latest version
// or
$post->lastVersion;
$post->versions->first(); // first version
// or
$post->firstVersion;
$post->versionAt('2022-10-06 12:00:00'); // get version from a specific time
// or
$post->versionAt(\Carbon\Carbon::create(2022, 10, 6, 12));
Revert
Revert a model instance to the specified version:
$post->getVersion(3)->revert();
// or
$post->revertToVersion(3);
$differOptions and $renderOptions are optional, you can set them following the README
of jfcherng/php-diff.
$stripTags allows you to remove HTML tags from the Diff, helpful when you don't want to show tags.
Using custom version model
You can define $versionModel in a model, that used this trait to change the model(table) for versions
Note
Model MUST extend class \Overtrue\LaravelVersionable\Version;
<?php
class PostVersion extends \Overtrue\LaravelVersionable\Version
{
//
}
Update the model attribute $versionModel:
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Overtrue\LaravelVersionable\Versionable;
class Post extends Model
{
use Versionable;
public string $versionModel = PostVersion::class;
}
Intergrations
mansoorkhan96/filament-versionable Effortlessly manage revisions of your Eloquent models in Filament.
:heart: Sponsor me
如果你喜欢我的项目并想支持它,点击这里 :heart:
Project supported by JetBrains
Many thanks to Jetbrains for kindly providing a license for me to work on this and other open-source projects.
Contributing
You can contribute in one of three ways:
File bug reports using the issue tracker.
Answer questions or fix bugs on the issue tracker.
Contribute new features or update the wiki.
The code contribution process is not very formal. You just need to make sure that you follow the PSR-0, PSR-1, and
PSR-2 coding guidelines. Any new code contributions must be accompanied by unit tests where applicable.
Does overtrue/laravel-versionable have a project website?
No homepage URL was recorded for overtrue/laravel-versionable in TopGit's last sync. The README tab above frequently contains screenshots and demo links, or check the repository description on GitHub.
How active is development on overtrue/laravel-versionable?
The most recent commit recorded on overtrue/laravel-versionable was 1 month ago, based on the GitHub push timestamp. The repository has 50 forks — one of the better signals of community interest.
How many stars does overtrue/laravel-versionable have?
overtrue/laravel-versionable has 588 GitHub stars — refresh the page for the live number, or check github.com/overtrue/laravel-versionable. TopGit mirrors GitHub's count but does not claim minute-by-minute accuracy.
What language is overtrue/laravel-versionable written in?
overtrue/laravel-versionable is written primarily in PHP. GitHub's language field is based on the largest share of bytes in the default branch.
What license does overtrue/laravel-versionable use?
overtrue/laravel-versionable is released under the MIT license. Always verify the LICENSE file directly on GitHub for the authoritative terms — license strings can be edited out of sync with a project's actual stance.
What topics is overtrue/laravel-versionable associated with?
GitHub's repository topics for overtrue/laravel-versionable: "laravel-model-versionable", "laravel-package", "laravel-reversion", "model-versioning". TopGit's editorial category is open-source.
Where do I read more about overtrue/laravel-versionable?
This TopGit page is a snapshot — the READ ME tab shows the project's own README content (links stripped, images preserved). The GitHub repository at github.com/overtrue/laravel-versionable is the definitive source.
Read full README in the tab above.
Want a second opinion on laravel-versionable?
Ask an AI that can read this page — one click and you get its take on laravel-versionable.