aristonis / laravel-livewire-dataview
this package manage livewire components to show set of item and handle quering of database
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/aristonis/laravel-livewire-dataview
Requires
- livewire/livewire: ^3.6
Requires (Dev)
- orchestra/testbench: ^9.15
- phpunit/phpunit: ^11.5
README
Laravel Livewire Dataview is a developer-focused toolkit for building SOLID-friendly data listing experiences in Livewire 3. It standardises how you configure queries, pagination and row rendering while keeping your components expressive and testable.
see docs
Features
- Opinionated abstract component (
DataViewComponent) that centralises pagination, queries and rendering. - Strongly validated traits for query definitions, pagination configuration and per-item views.
- Default Blade view that wires your per-item Livewire components and pagination links.
dataview:makeartisan command to scaffold a DataView component plus optional item component and Blade view.- Config publishing for project-wide defaults (
config/dataview.php) and reusable stubs for custom scaffolding.
Requirements
- PHP 8.2+
- Laravel 10.x or 11.x with Livewire 3.6+
- Composer and Node tooling if you plan to style the bundled Blade view
Installation
composer require aristonis/laravel-livewire-dataview
Optionally publish the package assets:
php artisan vendor:publish --tag=dataview-views # copues views component and customize it php artisan vendor:publish --tag=dataview-config # copies config/dataview.php php artisan vendor:publish --tag=dataview-stubs # copies stub templates
Quick start
-
Scaffold a dataview plus item component:
php artisan dataview:make Users/UserTable --with-item
-
Edit the generated component so it extends
Aristonis\LaravelLivewireDataview\DataViewComponentand configure the query, pagination and item view:<?php namespace App\Livewire\Users; use App\Models\User; use Aristonis\LaravelLivewireDataview\DataViewComponent; class UserTable extends DataViewComponent { protected function configure(): void { $this->setItemView('users.user-table-item'); $this->setPerPage(20); } protected function query() { return User::query()->with('roles')->orderByDesc('created_at'); } }
-
The generated Blade view (
resources/views/livewire/users/user-table-item.blade.php) receives each item through theitemprop. You can customise the markup as you see fit. -
Render the dataview in any Blade template:
<livewire:users.user-table />
The default package view (aristonis-dataview::livewire.dataview) loops through your collection and renders the configured item component with stable Livewire keys, then shows pagination links when the query returns a paginator.
Configuration
config/dataview.php controls the base behaviour:
pagination.per_page: global default for$this->getPerPage().pagination.enable: you can toggle pagination at runtime withenablePagination()/disablePagination().item.keyName: used when generating Livewire keys; override via$this->setKeyName('uuid').
Every component can override these defaults inside configure() to keep component logic predictable and SOLID.
Testing
composer test
The test suite relies on Orchestra Testbench. Please ensure new functionality is accompanied by unit or feature coverage.
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details on our workflow and coding standards.
License
The MIT License (MIT). Please see LICENSE for more information.