Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Filament Versionable Laravel Package

visualbuilder/filament-versionable

Filament plugin to manage Eloquent model revisions with polymorphic user support. View diffs, see who changed what, browse revision history, and restore any previous state. Built on visualbuilder/versionable for multi-user-model tracking.

View on GitHub
Deep Wiki
Context7

Packagist Version run-tests

Filament Versionable (Polymorphic User Fork)

Fork of mansoor/filament-versionable with polymorphic user support

This fork uses visualbuilder/versionable which supports polymorphic user relationships, enabling version tracking across multiple user model types (User, Admin, Associate, EndUser, OrganisationUser, etc.).

Version Compatibility

Package Version Filament Laravel PHP
5.x 5.x 11.x, 12.x 8.2+
4.x 4.x 10.x, 11.x 8.2+

Effortlessly manage your Eloquent model revisions in Filament. It includes:

  • A Filament page to show the Diff of what has changed and who changed it
  • A list of Revisions by different users
  • A Restore action to restore the model to any state

Installation

You can install the package via composer:

composer require visualbuilder/filament-versionable

Then, publish the config file and migrations:

php artisan vendor:publish --provider="Visualbuilder\Versionable\ServiceProvider"

Run the migration command:

php artisan migrate

[!IMPORTANT] If you have not set up a custom theme and are using Filament Panels follow the instructions in the Filament Docs first.

After setting up a custom theme add the plugin's views and css to your theme css file.

@import '../../../../vendor/visualbuilder/filament-versionable/resources/css/plugin.css';
@source '../../../../vendor/visualbuilder/filament-versionable/resources/**/*.blade.php';

Usage

Add Visualbuilder\Versionable\Versionable trait to your model and set $versionable attributes.

NOTE: Make sure to add protected $versionStrategy = VersionStrategy::SNAPSHOT; This would save all the $versionable attributes when any of them changed. There are different bug reports on using VersionStrategy::DIFF

use Visualbuilder\Versionable\VersionStrategy;

class Post extends Model
{
    use Visualbuilder\Versionable\Versionable;

    protected $versionable = ['title', 'content'];

    protected $versionStrategy = VersionStrategy::SNAPSHOT;
}

Create a Revisons Resource page to show Revisions, it should extend the Visualbuilder\FilamentVersionable\RevisionsPage. If you were to create a Revisions page for ArticleResource, it would look like:

namespace App\Filament\Resources\ArticleResource\Pages;

use App\Filament\Resources\ArticleResource;
use Visualbuilder\FilamentVersionable\RevisionsPage;

class ArticleRevisions extends RevisionsPage
{
    protected static string $resource = ArticleResource::class;
}

Next, Add the ArticleRevisions page (that you just created) to your Resource

use App\Filament\Resources\ArticleResource\Pages;

public static function getPages(): array
{
    return [
        ...
        'revisions' => Pages\ArticleRevisions::route('/{record}/revisions'),
    ];
}

Add RevisionsAction to your edit/view pages, this action would only appear when there are any versions for the model you are viewing/editing.

use Visualbuilder\FilamentVersionable\Page\RevisionsAction;

protected function getHeaderActions(): array
{
    return [
        RevisionsAction::make(),
    ];
}

You can also add the RevisionsAction to your table.

use Visualbuilder\FilamentVersionable\Table\RevisionsAction;

$table->actions([
    RevisionsAction::make(),
]);

You are all set! Your app should store the model states and you can manage them in Filament.

Customisation

If you want to change the UI for Revisions page, you may publish the publish the views to do so.

php artisan vendor:publish --tag="filament-versionable-views"

If you want more control over how the versions are stored, you may read the Visualbuilder Versionable Docs (based on overtrue/laravel-versionable).

Strip Tags from Diff

You can easily remove/strip HTML tags from the diff by just overriding shouldStripTags method inside your revisions page.

class ArticleRevisions extends RevisionsPage
{
    protected static string $resource = ArticleResource::class;

    public function shouldStripTags(): bool
    {
        return true;
    }
}

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky