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 Db Table State Laravel Package

kisame76/filament-db-table-state

Persist Filament table state (filters, sorting, search, pagination) in the database so users keep their preferred view between visits. Lightweight Laravel package for per-user table preferences across resources and sessions.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • State Management for Filament Tables: The package extends Laravel Filament’s table components by adding persistent state management (e.g., column visibility, sorting, filtering) via database storage. This aligns well with enterprise-grade applications requiring user-specific or role-based table configurations (e.g., admin dashboards, multi-tenant SaaS).
  • Filament Ecosystem Synergy: Since it’s built for Filament (a Laravel admin panel framework), it leverages Filament’s existing architecture (Blade, Livewire, or React components) without disrupting core workflows. Ideal for projects already using Filament.
  • Database-Driven Flexibility: Unlike client-side state (e.g., localStorage), this package stores state in the database, enabling server-side validation, audit trails, and multi-device sync. Critical for compliance-heavy or collaborative environments.

Integration Feasibility

  • Low Coupling: The package injects state management into Filament’s table classes with minimal boilerplate. Integration requires:
    • Adding the service provider (FilamentDbTableStateServiceProvider).
    • Configuring the model/table mappings in config/filament-db-table-state.php.
    • Extending Filament’s table classes (e.g., Table or Resource\Table) with the trait HasDbTableState.
  • Dependency Risks:
    • Filament Version Lock: Must match the Filament version the package supports (e.g., Filament v3.x). Downgrading/upgrading Filament may break compatibility.
    • Database Schema: Requires a migration table (filament_db_table_states). Schema changes (e.g., adding new state fields) may need manual adjustments.
    • Caching: If Filament uses caching (e.g., Redis), state retrieval may need caching layers to avoid DB hits on every request.

Technical Risk

Risk Severity Mitigation
Filament Version Drift High Pin Filament version in composer.json and test upgrades in a staging environment.
Performance Overhead Medium Benchmark DB queries for large tables; consider caching state for anonymous users.
State Serialization Medium Validate that custom table configurations (e.g., complex filters) serialize correctly.
Concurrency Issues Low Use database transactions for state updates if multiple users edit the same table simultaneously.
Vendor Lock-in Low Abstract state logic behind interfaces if future migration to another admin panel is needed.

Key Questions

  1. Use Case Alignment:
    • Is persistent table state a must-have (e.g., for power users) or a nice-to-have (e.g., optional for most users)?
    • Are there alternatives (e.g., localStorage, Filament’s built-in session state) that could reduce complexity?
  2. Scalability:
    • How will state bloat impact the database as the user base grows? (e.g., 10K users × 5 tables × state per table).
    • Is there a need to partition state by tenant (multi-tenancy) or user role?
  3. Customization Needs:
    • Does the package support custom state fields (e.g., pinned rows, custom column widths) out of the box?
    • Will extensions require monkey-patching Filament’s core classes?
  4. Testing:
    • How will state migrations be tested (e.g., upgrading from v1 to v2 of the package)?
    • Are there data integrity risks if state records become orphaned (e.g., deleted user but retained state)?

Integration Approach

Stack Fit

  • Primary Fit: Laravel + Filament (v2/v3) applications where:
    • Tables require persistent, user-specific configurations.
    • Database-backed state is preferred over client-side storage (e.g., for security/auditability).
  • Secondary Fit:
    • Projects using Filament’s React or Livewire variants (package likely supports both).
    • Applications needing role-based table defaults (e.g., admins see all columns; users see only relevant ones).
  • Non-Fit:
    • Non-Filament Laravel apps (would need significant refactoring).
    • Projects using client-side state management (e.g., Vue/React tables with localStorage).
    • Headless or API-only Laravel backends (no UI layer to benefit from table state).

Migration Path

  1. Assessment Phase:
    • Audit existing Filament tables to identify which require persistent state.
    • Document current state management (e.g., URL params, cookies) to avoid duplication.
  2. Setup:
    • Install the package:
      composer require kisame76/filament-db-table-state
      
    • Publish config and migration:
      php artisan vendor:publish --provider="Kisame76\FilamentDbTableState\FilamentDbTableStateServiceProvider"
      php artisan migrate
      
    • Configure config/filament-db-table-state.php with table-state mappings.
  3. Incremental Rollout:
    • Phase 1: Enable state for non-critical tables (e.g., logs, reports) to validate performance.
    • Phase 2: Migrate high-impact tables (e.g., CRM dashboards) with fallback mechanisms (e.g., session storage if DB fails).
    • Phase 3: Deprecate legacy state management (e.g., URL params) in favor of the new system.
  4. Testing:
    • Unit Tests: Mock Filament tables to verify state serialization/deserialization.
    • E2E Tests: Simulate user workflows (e.g., column resizing, sorting) across devices/browsers.
    • Load Tests: Measure DB impact with concurrent users (e.g., 100+ users editing states simultaneously).

Compatibility

  • Filament Versions: Confirm compatibility with the exact Filament version in use (e.g., filament/filament: ^3.0).
  • Laravel Versions: Check if the package supports the Laravel LTS version (e.g., 10.x, 11.x).
  • Database Support: Test with the primary database (MySQL, PostgreSQL, SQLite) and edge cases (e.g., read replicas).
  • Caching Layers: If using Redis/Memcached, ensure state retrieval doesn’t bypass cache unintentionally.
  • Custom Filament Extensions: Verify compatibility with:
    • Custom table columns (e.g., ToggleColumn, SelectColumn).
    • Third-party Filament plugins (e.g., filament-spatie-laravel-permission).

Sequencing

  1. Pre-requisites:
    • Upgrade Filament to a supported version if necessary.
    • Ensure the database schema can handle additional tables/indexes.
  2. Core Integration:
    • Extend base Filament Table class with HasDbTableState.
    • Configure state fields (e.g., columns, sort, filters) in the config.
  3. UI/UX Adjustments:
    • Update table headers/footers to indicate state persistence (e.g., "Saved for you").
    • Add a reset state button for power users.
  4. Post-Launch:
    • Monitor state bloat and optimize queries (e.g., add indexes).
    • Implement state export/import for data migration.

Operational Impact

Maintenance

  • Proactive Tasks:
    • Schema Updates: Monitor package releases for migration changes (e.g., adding archived_at to state table).
    • Backup Strategy: Include filament_db_table_states in database backups; test restores.
    • Deprecation: Plan for Filament major version upgrades (package may lag).
  • Reactive Tasks:
    • State Corruption: Implement a repair script for orphaned records (e.g., user_id not found).
    • Performance Degradation: Optimize slow queries (e.g., add user_id index if querying by user).
  • Tooling:
    • Add database monitoring for the state table (e.g., size growth, query latency).
    • Use Laravel Telescope to debug state serialization issues.

Support

  • Troubleshooting:
    • Common Issues:
      • State not saving: Verify HasDbTableState trait is applied and config is correct.
      • State loading slowly: Check for N+1 queries or missing indexes.
      • Serialization errors: Ensure custom table classes implement JsonSerializable.
    • Debugging Tools:
      • Log state payloads before/after DB operations.
      • Use tinker to inspect state records:
        \Kisame76\FilamentDbTableState\Models\TableState::where('table', 'users')->get();
        
  • Documentation Gaps:
    • The package lacks migration guides (e.g., upgrading from v1 to v2).
    • Customization docs are minimal (e.g., adding new state fields).
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.
besmartand-pro/php-quality-config
sentix/ai-chatbot
terminal42/code-quality-tools
codifyo/ts-generator-bundle
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