- How do I integrate timolake/livewire-tables into an existing Laravel Livewire 3.x project?
- Install via Composer with `composer require timolake/livewire-tables`, then extend the `LivewireTable` class in your controller. Define columns, search fields, and queries in the `configure()` and `query()` methods. The package replaces manual table loops with a single reusable component, requiring minimal changes to your existing Livewire components.
- Does this package support Laravel 10/11 and Livewire 3.x specifically?
- Yes, the package explicitly targets Livewire 3.x, ensuring compatibility with Laravel 10 and 11. It leverages Livewire’s latest features like Blade components and file-based routing. However, check the Livewire upgrade guide if you plan to migrate to future versions, as breaking changes may affect compatibility.
- Can I customize the table styling or add complex UI features like nested rows?
- The package provides minimal default styling to avoid frontend dependencies. For custom UI, override the Blade template or use CSS. Complex features like nested rows or dynamic columns require manual Blade overrides or additional JavaScript. The package focuses on server-side logic, leaving UI flexibility to developers.
- How does pagination, search, and sorting work under the hood? Is it client-side or server-side?
- All operations—pagination, search, and sorting—are handled server-side via Eloquent queries. The package generates reactive Livewire components that send user inputs (e.g., search terms, sort orders) to the server, where Eloquent processes them. This avoids client-side JavaScript and keeps data processing secure and efficient.
- What if my dataset is very large (e.g., 50K+ rows)? Will this package perform well?
- For large datasets, performance depends on database optimization. Use indexes on search/sort columns and consider cursor-based pagination (e.g., `cursor()`) instead of offset-based. The package itself relies on Eloquent, so inefficient queries or unoptimized tables may slow down responses. Test with your actual data volume before production use.
- Does timolake/livewire-tables support bulk actions or row-level actions like editing/deleting?
- The package doesn’t include built-in bulk actions, but you can extend it using traits or custom methods. Row-level actions (e.g., edit/delete buttons) are supported via Blade directives in the table template. For bulk operations, you’d need to implement additional logic in the `LivewireTable` class or use JavaScript for client-side confirmation.
- How does session state management work? Will it cause issues in a high-traffic app?
- The package persists user preferences (sort, pagination, search) in the session, which is managed by Livewire. For high-traffic apps, session bloat can occur. Mitigate this by using database-backed sessions or implementing lazy-loading for large datasets. Avoid storing excessive state in the session for shared environments.
- Are there alternatives to this package for Laravel Livewire datatables? How does it compare?
- Alternatives include `livewire-powergrid` (more features but heavier) and `livewire-datatables` (client-side JS). This package stands out for its server-side-only approach, minimal dependencies, and Eloquent-centric design. It’s lighter than PowerGrid but lacks built-in exports or advanced filtering. Choose based on your need for simplicity vs. feature richness.
- Can I use this package with non-Eloquent data sources, like API responses or raw arrays?
- The package is optimized for Eloquent ORM and assumes query-building methods like `setSearch()` and `setSort()`. For non-Eloquent data, you’d need to manually implement the `query()` method or extend the package. It’s not designed for raw arrays or API responses out of the box, so Eloquent models are strongly recommended.
- How do I test this package in my Laravel application? Are there edge cases to consider?
- Test with empty datasets, special characters in search fields, and large pagination limits. Use Livewire’s built-in testing tools to simulate user interactions (e.g., sorting, searching). Edge cases like concurrent users or session timeouts should also be validated. The package’s minimal test coverage means you may need to add custom assertions for your specific use case.