- How do I install ElectricGrid in a Laravel 10+ project with Livewire 3.x?
- Run `composer require tomshaw/electricgrid` followed by `php artisan electricgrid:install`. This sets up Vite directives for assets and publishes the Blade component. Ensure your `vite.config.js` includes the package’s CSS/JS directives, and rebuild assets with `npm run dev`.
- Can ElectricGrid work with non-Eloquent data sources like API responses or arrays?
- Yes, ElectricGrid supports Eloquent models *and* in-memory data (Collections/arrays). Pass a `Collection` or array to the `data` prop in your Livewire component, but note that server-side filtering/sorting will require Eloquent queries for optimal performance.
- What Laravel and Livewire versions does ElectricGrid officially support?
- ElectricGrid is tested for **Laravel 10+** and **Livewire 3.x**. It assumes PHP 8.2+. If using Livewire 2.x, check for breaking changes, as the package relies on Livewire 3’s reactivity model and new features like `wire:ignore`.
- How do I customize the table’s styling beyond the default Tailwind classes?
- Override styles via CSS by targeting the Blade component’s classes (e.g., `.electricgrid-row-hover`). Use `@layer` in your CSS file to ensure specificity. For dark mode, extend Tailwind’s `dark:` classes or replace hex colors in the package’s default stylesheet.
- Does ElectricGrid handle row-level permissions (e.g., restricting row clicks to admins)?
- No, ElectricGrid doesn’t include built-in ACLs. Enforce permissions in your Livewire component’s `rowClick` handler using Laravel’s `authorize()` or middleware. For example, check `auth()->user()->can('edit', $row)` before redirecting.
- What’s the best way to test ElectricGrid in a CI pipeline?
- Run `php artisan test` to execute ElectricGrid’s unit tests. For integration tests, mock Livewire components and verify state updates (e.g., `$this->assertEquals(2, $this->perPage)`). Test exports separately with tools like `spatie/laravel-pdf` or `maatwebsite/excel`.
- How do I optimize ElectricGrid for large datasets (e.g., 10,000+ rows)?
- Use **server-side filtering/sorting** with Eloquent’s `where`/`orderBy` to avoid client-side processing. Enable **infinite scroll** for pagination, and preload relations with `with()` to reduce N+1 queries. For exports, consider queueing PDF/Excel generation.
- Can I use ElectricGrid with Laravel Mix instead of Vite?
- ElectricGrid requires Vite for asset compilation. If using Mix, configure aliases in `vite.config.js` to point to the package’s assets, then rebuild with `npm run dev`. Alternatively, manually include the CSS/JS files via CDN, but this may break reactivity.
- Are there alternatives to ElectricGrid for Laravel/Livewire tables?
- Yes. For simpler tables, consider `livewire/tables` (built into Livewire). For advanced features, evaluate `filament-tables`, `spatie/laravel-data-tables`, or `archtechx/tables`. ElectricGrid stands out for its **export flexibility** and **modular filters/actions** without bloat.
- How do I add a custom filter (e.g., a range slider) to ElectricGrid?
- Extend the `Filter` class in your Livewire component. For a range slider, add a `wire:model` property (e.g., `public $minPrice, $maxPrice`), then bind it to a custom filter method like `applyPriceRange()`. Use the `filters` prop to include it in the table config.