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

Technical Evaluation

Architecture Fit

  • Pros:

    • Filament Integration: Tightly integrated with Filament 5.x, leveraging its UI components (Resources, Pages, Actions) for seamless adoption. Aligns with modern Laravel admin panel patterns.
    • Polymorphic User Support: Extends visualbuilder/versionable (fork of overtrue/laravel-versionable), enabling version tracking across multiple user models (e.g., User, Admin, OrganisationUser). Critical for multi-role systems (e.g., SaaS platforms, enterprise apps).
    • Snapshot/Diff Strategies: Supports both full snapshots (VersionStrategy::SNAPSHOT) and diff-based tracking (though the README warns of bugs with DIFF). Snapshot is recommended for reliability.
    • Filament UI: Provides a dedicated Revisions Page with diff visualization, restore functionality, and user attribution—reducing custom dev effort for audit trails.
    • Translation-Ready: Supports 7+ languages (French, German, Dutch, Czech, Chinese, etc.), useful for global products.
  • Cons:

    • Limited Adoption: 0 stars/dependents and MIT license (no commercial guarantees). Risk of abandonment or undocumented edge cases.
    • Filament 5.x Only: Breaking changes may require updates if migrating from Filament 4.x (though v5.0.0 claims backward compatibility).
    • Storage Overhead: Snapshot strategy stores full copies of versioned attributes, which could bloat databases for high-frequency updates (e.g., CMS content).
    • No Built-in Soft Deletes: Versioned models may not inherit Filament’s soft-delete behavior by default (requires manual setup).

Integration Feasibility

  • Core Laravel Compatibility:
    • Laravel 11/12: Tested on latest LTS versions.
    • PHP 8.2+: No major deprecations expected.
    • Livewire 4.x: Works with Filament’s Livewire foundation.
  • Filament-Specific:
    • Requires Filament 5.x (no Filament 4.x support in v5.x).
    • Custom Theme Needed: Must publish CSS/views to Filament’s theme (blocking for non-themed setups).
    • Resource Integration: Adds a new page type (RevisionsPage) and actions (RevisionsAction), which must be manually linked to existing resources.
  • Database:
    • Publishes migrations for version tables (no schema conflicts if using visualbuilder/versionable directly).
    • Polymorphic Users: Requires user models to implement Illuminate\Contracts\Auth\MustVerifyEmail or similar (check visualbuilder/versionable docs).

Technical Risk

  • High:
    • Undocumented Bugs: VersionStrategy::DIFF has known issues (README warns against it). Snapshot may not suit all use cases (e.g., large BLOBs).
    • Performance: Snapshot strategy could increase storage for frequently updated models (e.g., blog posts with rich text).
    • Filament Version Lock: Tied to Filament 5.x; upgrades may require package updates.
    • Polymorphic User Complexity: Misconfigured user models could break version attribution.
  • Mitigation:
    • Test Thoroughly: Validate snapshot storage limits and diff accuracy.
    • Monitor Database Growth: Set alerts for version table bloat.
    • Fallback Plan: Use overtrue/laravel-versionable directly if Filament UI isn’t critical.

Key Questions

  1. Use Case Alignment:
    • Is polymorphic user support essential (e.g., multi-role systems)? If not, the original mansoor/filament-versionable may suffice.
    • Are full snapshots acceptable, or is a hybrid approach (e.g., diff for text, snapshot for metadata) needed?
  2. Scalability:
    • What’s the expected update frequency for versioned models? (e.g., 100K updates/month → storage costs?)
    • Are large fields (e.g., HTML/CKEditor content) being versioned? If yes, consider compressing snapshots.
  3. Filament Constraints:
    • Is the team already using Filament 5.x? If not, upgrade effort must be factored in.
    • Can custom themes be implemented for CSS/view integration?
  4. Alternatives:
    • Compare with spatie/laravel-activitylog (lighter, but lacks Filament UI).
    • Evaluate laravel-nova-versioning if using Nova instead of Filament.
  5. Maintenance:
    • Who will triage issues if bugs arise (e.g., restore failures)?
    • Is there a rollback plan if the package becomes unmaintained?

Integration Approach

Stack Fit

  • Primary Stack:
    • Laravel 11/12 + Filament 5.x + PHP 8.2+: Full compatibility.
    • Livewire 4.x: Underlying Filament dependency is satisfied.
  • Secondary Stack:
    • Polymorphic Users: Requires user models to implement Visualbuilder\Versionable\Contracts\VersionableUser (check visualbuilder/versionable docs).
    • Database: MySQL/PostgreSQL (no engine-specific constraints).
  • Anti-Patterns:
    • Filament 4.x: Incompatible with v5.x of this package.
    • Non-Filament Admin Panels: (e.g., Nova, Backpack) require alternative solutions.

Migration Path

  1. Pre-Integration:
    • Audit Dependencies: Ensure filament/filament:^5.0, laravel/framework:^11.0, and php:^8.2.
    • Backup Database: Migrations alter schema (version tables).
    • Theme Setup: Publish Filament’s custom theme (blocker if not already configured).
  2. Installation:
    composer require visualbuilder/filament-versionable
    php artisan vendor:publish --provider="Visualbuilder\Versionable\ServiceProvider"
    php artisan migrate
    
  3. Model Integration:
    • Add use Visualbuilder\Versionable\Versionable; trait to target models.
    • Define $versionable attributes and $versionStrategy (prefer SNAPSHOT).
    • Example:
      class Post extends Model {
          use Visualbuilder\Versionable\Versionable;
          protected $versionable = ['title', 'content'];
          protected $versionStrategy = VersionStrategy::SNAPSHOT;
      }
      
  4. Filament Resource Integration:
    • Extend RevisionsPage for each resource:
      class PostRevisions extends RevisionsPage {
          protected static string $resource = PostResource::class;
      }
      
    • Register the page in the resource’s getPages():
      public static function getPages(): array {
          return [
              'revisions' => Pages\PostRevisions::route('/{record}/revisions'),
          ];
      }
      
    • Add RevisionsAction to edit/view pages and tables:
      protected function getHeaderActions(): array {
          return [RevisionsAction::make()];
      }
      
  5. Post-Integration:
    • Test Restore: Verify snapshots can be rolled back without data corruption.
    • Monitor Storage: Check version table growth (e.g., versions table).
    • Customize UI: Publish views if styling needs adjustment:
      php artisan vendor:publish --tag="filament-versionable-views"
      

Compatibility

  • Filament Plugins: May conflict if they modify the same model events (e.g., saving, updating). Test with filament/spatie-laravel-medialibrary or similar.
  • Caching: Versioned models may bypass cache if not handled (e.g., Cache::remember with model IDs).
  • Queues: Async updates (e.g., dispatch()) could desync versioning if not atomic.

Sequencing

  1. Phase 1: Core Setup (1–2 days):
    • Install package, publish migrations/config.
    • Integrate with 1–2 critical models (e.g., Post, Product).
  2. Phase 2: Filament UI (1 day):
    • Add RevisionsPage and actions to resources.
    • Test diff visualization and restore.
  3. Phase 3: Validation (1–2 days):
    • Load test with high-frequency updates (e.g., 1K/month).
    • Verify storage impact and performance.
  4. Phase 4: Rollout (Ongoing):
    • Gradually enable for other models.
    • Monitor for edge cases (e.g., concurrent edits).

Operational Impact

Maintenance

  • Pros:
    • Minimal Code Changes: Most logic is handled by traits/actions.
    • Centralized Config: Package manages migrations, events,
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