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

Laravel Livewire Tables Laravel Package

alp-develop/laravel-livewire-tables

Reactive Livewire data tables for Laravel—search, sort, filter, paginate, export, and bulk actions with zero JavaScript. Supports Laravel 10–13, Livewire 3–4, PHP 8.1+, Tailwind or Bootstrap 4/5, plus dark mode and configurable themes.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Pipeline Pattern: The package leverages a modular pipeline (search, filter, sort) for query building, which aligns well with Laravel’s Eloquent and Livewire’s reactive nature. This ensures clean separation of concerns and extensibility via custom steps.
  • Livewire Integration: Built for Livewire 3/4, it abstracts away JavaScript complexity while maintaining reactivity. The state management (sorting, filtering, pagination) is handled server-side, reducing client-side overhead.
  • Theming Flexibility: Supports Tailwind, Bootstrap 4/5, and dark mode, making it adaptable to existing UI systems. Themes are configurable via a single setting, minimizing CSS conflicts.
  • Column/Filter System: Column types (Text, Boolean, Action, etc.) and filter types (Select, DateRange, etc.) are pluggable, allowing for domain-specific customization without reinventing the wheel.

Integration Feasibility

  • Laravel 10+ Compatibility: Requires minimal setup (composer install, config publish) and works with modern Laravel features (e.g., Eloquent relationships, query scopes).
  • Livewire Dependency: Assumes Livewire is already in use. If not, this would require adopting Livewire as a prerequisite.
  • Database Agnostic: Works with any Eloquent model, including complex queries (joins, subqueries) via the pipeline pattern.
  • Blade Integration: Lightweight Blade components for rendering tables, with support for dynamic table-key to isolate state across multiple instances.

Technical Risk

  • Livewire Version Lock: Tied to Livewire 3/4. Upgrades to Livewire 5+ may require package updates or forks.
  • Performance at Scale: Heavy tables (e.g., 100K+ rows) may strain the pipeline if not optimized (e.g., lazy-loading, cursor pagination). The package lacks built-in virtual scrolling.
  • Customization Depth: While extensible (custom steps, filters, columns), deep customizations (e.g., replacing the entire pipeline) require overriding core methods, which could lead to maintenance overhead.
  • Dark Mode Implementation: Relies on client-side CSS toggling and session sync, which may need additional logic for SSO or multi-tab scenarios.

Key Questions

  1. Livewire Adoption: Is Livewire already in use, or would this require a migration? If not, what’s the cost/benefit of adopting it for this feature?
  2. Query Complexity: Are tables expected to handle nested relationships, complex joins, or real-time data? If so, how will the pipeline pattern scale?
  3. Theming Constraints: Does the existing UI system (e.g., custom CSS, legacy Bootstrap 3) conflict with the package’s themes? Would custom theming be required?
  4. Bulk Actions: Are bulk actions (e.g., delete, export) critical, or can they be implemented via custom Livewire logic?
  5. Dark Mode: Is dark mode a must-have, or is it a nice-to-have that can be implemented separately?
  6. Testing: Are there existing tests for table components? If not, how will test coverage be maintained for custom tables?
  7. Fallbacks: What’s the plan for graceful degradation if the package or Livewire fails (e.g., server errors, JavaScript disabled)?

Integration Approach

Stack Fit

  • Laravel + Livewire: Ideal fit. The package is designed to work seamlessly with Livewire’s reactive model, reducing client-side JavaScript.
  • Eloquent Models: Assumes Eloquent is used for data access. Raw SQL or non-Eloquent queries would require custom steps or wrappers.
  • Frontend Frameworks: Compatible with Tailwind, Bootstrap 4/5, or custom CSS. If using a different framework (e.g., Alpine.js, Inertia), additional styling may be needed.
  • Authentication: Works with Laravel’s auth system (e.g., gated routes, policies) but doesn’t enforce it. Bulk actions should include authorization checks.

Migration Path

  1. Assess Livewire Dependency:
    • If Livewire isn’t used, evaluate the effort to adopt it (e.g., migrating existing forms/tables to Livewire components).
    • Start with a single table (e.g., admin dashboard) to test integration.
  2. Installation:
    • Install via Composer: composer require alp-develop/laravel-livewire-tables.
    • Publish config: php artisan vendor:publish --tag=livewire-tables-config.
    • Configure theme (e.g., tailwind) and dark mode settings.
  3. Incremental Adoption:
    • Replace one legacy table at a time with the new component (e.g., <livewire:tables.users-table />).
    • Use table-key to isolate state for multiple instances (e.g., filtered vs. unfiltered views).
  4. Customization:
    • Extend the pipeline for complex queries (e.g., custom StepContract for soft deletes).
    • Override configure() for per-table defaults (e.g., setDefaultPerPage(50)).
  5. Testing:
    • Test edge cases: empty datasets, bulk actions, export formats.
    • Verify dark mode toggling and session persistence.

Compatibility

  • Laravel Versions: Confirmed compatibility with Laravel 10–13. Test thoroughly if using Laravel 14+.
  • PHP 8.1+: Requires PHP 8.1+. Use php -v to check and update if needed.
  • Livewire 3/4: Ensure Livewire is updated to a supported version (e.g., livewire/livewire:^4.0).
  • Frontend Assets: Tailwind/Bootstrap CSS must be loaded. For custom themes, extend the package’s CSS or override styles.
  • Database: Works with MySQL, PostgreSQL, SQLite, etc., but complex queries (e.g., full-text search) may need Eloquent scopes.

Sequencing

  1. Phase 1: Core Tables
    • Replace CRUD tables (list, edit, delete) with livewire-tables.
    • Focus on read-heavy tables first (e.g., dashboards, reports).
  2. Phase 2: Advanced Features
    • Add bulk actions (e.g., export, delete) and custom filters.
    • Implement dark mode if needed.
  3. Phase 3: Optimization
    • Optimize slow queries (e.g., add indexes, lazy-load relationships).
    • Customize themes or pipeline steps for edge cases.
  4. Phase 4: Rollout
    • Gradually replace legacy tables in features.
    • Monitor performance and user feedback.

Operational Impact

Maintenance

  • Package Updates: Monitor for breaking changes (e.g., Livewire 5+ compatibility). Use composer why-not to check for conflicts.
  • Custom Code: Custom steps/filters/columns may diverge from upstream. Document dependencies and test upgrades.
  • Configuration: Centralize table settings (e.g., config/livewire-tables.php) to avoid duplication.
  • Deprecations: Livewire 3 is EOL; plan to migrate to Livewire 4+ if not already done.

Support

  • Troubleshooting:
    • Use dd($this->state) in configure() to debug query state.
    • Check Livewire logs (storage/logs/livewire.log) for errors.
    • Verify session storage (e.g., session()->all()) for dark mode or state issues.
  • Common Issues:
    • Shared State: Forgetting table-key causes all instances to sync. Always use unique keys for multiple tables.
    • Query Performance: Complex pipelines may slow down. Use DB::enableQueryLog() to profile.
    • CSS Conflicts: Custom themes may override package styles. Use !important sparingly; prefer scoped classes.
  • Documentation: The package’s docs are comprehensive, but internal teams may need runbooks for:
    • Creating a new table (php artisan make:livewiretable).
    • Customizing the pipeline or adding bulk actions.

Scaling

  • Performance:
    • Pagination: Defaults to setDefaultPerPage(25). Adjust based on user needs (e.g., 50–100 for analytics).
    • Indexes: Ensure columns used in sortable()/searchable() are indexed.
    • Caching: The pipeline caches the Engine instance per request, reducing overhead.
    • Exports: Large CSV exports may time out. Use chunking or queue jobs for bulk actions.
  • Concurrency:
    • Livewire handles concurrent requests, but bulk actions (e.g., deleteSelected) should use transactions or queues to avoid race conditions.
    • Example:
      public function deleteSelected(): void
      {
          User::whereIn('id', $this->getSelectedIds())->delete();
      }
      
      → Wrap in a transaction or dispatch to a queue:
      DeleteUsersJob::dispatch($this->getSelectedIds());
      
  • Database Load:
    • Avoid SELECT * in queries. Use select() to fetch only needed columns.
    • For read-heavy tables, consider caching the base query (e.g., query()->remember()).

Failure Modes

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.
codraw/entity-migrator
codraw/doctrine-extra
codraw/aws-tool-kit
codraw/validator
codraw/workflow
codraw/open-api
codraw/cron-job
codraw/process
codraw/log
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony