Search by

elvin-qulizade / filament-versions

Elvin-Qulizade

Snapshot-based version history and restore for Filament resources

Package info

github.com/Elvin-Qulizade/filament-versions

Homepage

Issues

pkg:composer/elvin-qulizade/filament-versions

Fund package maintenance!

Elvin-Qulizade

Statistics

Installs: 132

Dependents: 0

Suggesters: 0

Stars: 3

v1.0.0 2026-09-29 11:36 UTC

This package is auto-updated.

Last update: 2026-11-03 02:35:13 UTC


README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Adds WordPress-style version history to any Eloquent model used in a Filament v5 resource: every save is snapshotted, a "History" tab shows the timeline with a field-level diff, and any past version can be restored with one click.

Installation

You can install the package via composer:

composer require elvin-qulizade/filament-versions

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 to your theme css file or your app's css file if using the standalone packages.

@source '../../../../vendor/elvin-qulizade/filament-versions/resources/**/*.blade.php';

You can publish and run the migrations with:

php artisan vendor:publish --tag="filament-versions-migrations"
php artisan migrate

You can publish the config file with:

php artisan vendor:publish --tag="filament-versions-config"

Optionally, you can publish the views using

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

This is the contents of the published config file:

return [
    // Attributes never stored in a version snapshot, on top of any
    // model-level $versionExcept property.
    'excluded_attributes' => [
        'password',
        'remember_token',
        'created_at',
        'updated_at',
    ],

    // Maximum number of versions kept per model instance. Older versions
    // are pruned automatically after each save, and via `versions:prune`.
    'max_versions_per_model' => 50,

    // Optional callable(Version $version): bool to gate the "Restore" action.
    // Left null, restoring is allowed for anyone who can see the History tab.
    'authorize_restore' => null,

    // Global retroactive cleanup, on top of the automatic per-save pruning
    // above. Off by default since per-save pruning already keeps storage
    // bounded for new versions.
    'schedule' => [
        'enabled' => false,
        'cron' => '0 3 * * *',
    ],
];

Usage

  1. Add the trait and contract to any Eloquent model you want version history for:
use ElvinQulizade\Versions\Concerns\HasVersions;
use ElvinQulizade\Versions\Contracts\Versionable;

class Post extends Model implements Versionable
{
    use HasVersions;
}
  1. Register the History tab on the model's Filament resource:
use ElvinQulizade\Versions\Filament\RelationManagers\VersionsRelationManager;

public static function getRelations(): array
{
    return [
        VersionsRelationManager::class,
    ];
}

That's it — every create/update is snapshotted automatically, the Edit page gets a "History" tab with a timeline, a field-level diff per version, and a one-click "Restore" action. To exclude fields from just one model in code, define protected array $versionExcept = [...] on it — or use the "Excluded fields" button on the History tab to manage it from the panel instead, per model class.

Select any two rows in the History table and use the "Compare" bulk action to diff them directly against each other, instead of only against the previous version.

Soft-deleted owner records keep working: their history and restore action remain reachable even while trashed.

Old versions beyond max_versions_per_model are pruned automatically after each save. To prune retroactively (e.g. after lowering the limit), run:

php artisan versions:prune
php artisan versions:prune --model="App\Models\Post" --keep=20

To run that automatically instead, set schedule.enabled to true in the config file (and schedule.cron if you want something other than daily at 3am).

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.