power-components/livewire-powergrid
Livewire PowerGrid lets you build modern, customizable data tables for Laravel Livewire in minutes. Get sorting, searching, filters, editable fields, action buttons, checkboxes, and export with minimal configuration—ready to use out of the box.
Install the package via Composer: composer require power-components/livewire-powergrid. Publish the config and assets: php artisan vendor:publish --tag=powergrid-config and --tag=powergrid-public. Create a PowerGrid table class using the Artisan command: php artisan make:power-grid-table PostTable. In your Blade view, render the table with @livewire('post-table').
Start with the minimal example: define columns (addColumns), data source (DataSource), and basic formatting. For new features, explore lifecycle hooks (e.g., transformQuery, transformActions, transformRows) and custom search handlers in your table class.
Note: If using a Collection datasource, ensure your datasource() method does not trigger duplicate calls (fixed in v6.10.1).
Use PowerGridComponent as the base class for all tables. Define data sources imperatively using Eloquent models, collections, or raw queries via datasource().
transformQuery, transformActions, and transformRows to modify behavior dynamically. For example, use transformQuery to inject custom query scopes or modify the query builder before execution.
public function transformQuery($query)
{
$query->where('active', true);
}
SearchHandler with your own implementation for advanced search logic. Define it in your table class:
public function searchHandler()
{
return new CustomSearchHandler();
}
batchActions() and ensure they align with your custom search logic.detail(), header(), or footer() slots for expandable rows or totals. For complex rendering, use th() or td() closures with caution—return plain strings or valid HTML.datasource() method was called twice when using a Collection. This has been fixed in v6.10.1. No additional action is required unless you were explicitly relying on this behavior.transformQuery, as they execute before data fetching.SearchHandler or implements the required methods. Debug by logging search payloads in the handler’s handle() method.mount()—initialize data lazily with DataSource. Use remember() sparingly, as it can cause stale data if not paired with cache invalidation or reactivity.datasource() method was called twice when using a Collection. If you were debugging or relying on this behavior, ensure your logic is updated to avoid duplicate operations.dd() in lifecycle hooks (e.g., transformQuery) for debugging, but remove before production.$search parameter in handle() to verify input:
public function handle($search)
{
\Log::debug('Search payload:', $search);
// Custom logic here
}
datasource() method is not being called redundantly (fixed in v6.10.1).pg-{component}) in resources/vendor/powergrid.transformQuery to inject soft deletes, scopes, or conditional clauses dynamically.transformRows to modify row data before rendering (e.g., formatting dates or adding computed fields). Example:
public function transformRows($rows)
{
return $rows->map(function ($row) {
$row->formatted_date = $row->created_at->format('Y-m-d');
return $row;
});
}
How can I help you explore Laravel packages today?