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

0.1.0 2025-11-20 08:41 UTC

This package is auto-updated.

Last update: 2025-11-24 04:08:41 UTC


README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

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:make artisan 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

  1. Scaffold a dataview plus item component:

    php artisan dataview:make Users/UserTable --with-item
  2. Edit the generated component so it extends Aristonis\LaravelLivewireDataview\DataViewComponent and 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');
        }
    }
  3. The generated Blade view (resources/views/livewire/users/user-table-item.blade.php) receives each item through the item prop. You can customise the markup as you see fit.

  4. 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 with enablePagination() / 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.