Livewire DataTables components for back-end. Modular, easy to use, with tons of features.

Overview

Livewire DataTables

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

Livewire DataTables components for back-end. Modular, easy to use, with tons of features.

Inspired by Caleb's Livewire Screencasts, dedicated to my friend Bardh.

Installation

You can install the package via composer:

composer require amirami/livewire-datatables

You can publish the config file with:

php artisan vendor:publish --provider="Amirami\LivewireDataTables\LivewireDataTablesServiceProvider" --tag="livewire-datatables-config"

This is the contents of the published config file:

return [

    'multi_column_sorting' => false,

    'row_caching' => false,

];

This means that by default these two options are disabled. But you can enable them for individual components.

Usage

After creating your Livewire component, extend the component class with Amirami\LivewireDataTables\DataTable. The DataTable abstract class will ask you to implement getQueryProperty method. This is a computed property in Livewire which needs to return and instance of Illuminate\Database\Eloquent\Builder or \Illuminate\Database\Eloquent\Relations\Relation.

This is the part where you will build the base of your query, with filters.

namespace App\Http\Livewire;

use App\Models\Post;
use Amirami\LivewireDataTables\DataTable;
use Illuminate\Database\Eloquent\Builder;

class PostsIndex extends DataTable
{
    public function getQueryProperty(): Builder
    {
        return Post::query();
    }

    public function render()
    {
        $posts = $this->entries;

        return view('livewire.posts-index', compact('posts'));
    }
}

This is the most basic component without any datatable features. Although it is totally fine to use the datatable without any features, it kinda beats the purpose of this package. Now let's get onto the many features this package provides.

Pagination

Pagination offers exactly the same features as Livewire's default one. It actually extends it. The only reason you'll have to use the pagination provided by this package is because Livewire's default one doesn't play nice with our other features.

namespace App\Http\Livewire;

use Amirami\LivewireDataTables\DataTable;
use Amirami\LivewireDataTables\Traits\WithPagination;

class PostsIndex extends DataTable
{
    use WithPagination;
}

You can configure how many result you want to see per page as well. If not defined the paginator will pull the default number from the model class.

namespace App\Http\Livewire;

use Amirami\LivewireDataTables\DataTable;
use Amirami\LivewireDataTables\Traits\WithPagination;

class PostsIndex extends DataTable
{
    use WithPagination;
    
    // As a property.
    public $perPage = 20;
    
    // Or as a method.
    public function getPerPage(): ?int
    {
        return 42;
    }
}

For everything else about pagination check out the Livewire's official documentation.

Searching

If you want to use rows searching you have to use WithSearching trait, bind an input to a component property and define searchable columns. Consider the rest handled. This is how easy it is:

namespace App\Http\Livewire;

use Amirami\LivewireDataTables\DataTable;
use Amirami\LivewireDataTables\Traits\WithSearching;

class PostsIndex extends DataTable
{
    use WithSearching;
    
    public $searchableColumns = [
        'title',
        'content',
    ];
    
    public function render()
    {
        $posts = $this->entries;

        return view('livewire.posts-index', compact('posts'));
    }
}
<input wire:model="search" type="text">

<table>
    <thead>
        <tr>
            <th>Title</th>
            <th>Excerpt</th>
            <th>Author</th>
            <th>Status</th>
        </tr>
    </thead>
    <tbody>
        @foreach($posts as $post)
            <tr>
                <th>{{ $post->title }}</th>
                <th>{{ $post->excerpt }}</th>
                <th>{{ $post->user->name }}</th>
                <th>{{ $post->status() }}</th>
            </tr>
        @endforeach
    </tbody>
</table>

Sorting

Filtering

Row Caching

Planned Features

  • Searching, sorting and filtering by relationship fields
  • Bulk Actions
  • Row Grouping
  • Front-end components (will most-likely be a separate package)

Showcase

Check out cool datatables built with livewire-datatables here, and don't forget to share your own 🙌 .

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

You might also like...
A package for defining scoped styles in Livewire components

A package for defining scoped styles in Livewire components

Declare routes inside Laravel Livewire components.

Convoy This package allows you to declare routes inside of your full page Laravel Livewire components. All you have to do is create a route method ins

This package allows you to render livewire components like a blade component, giving it attributes, slots etc

X-livewire This package allows you to render livewire components like a blade component, giving it attributes, slots etc. Assuming you wanted to creat

Laravel User Activity Log - a package for Laravel 8.x that provides easy to use features to log the activities of the users of your Laravel app
Laravel User Activity Log - a package for Laravel 8.x that provides easy to use features to log the activities of the users of your Laravel app

Laravel User Activity Log - a package for Laravel 8.x that provides easy to use features to log the activities of the users of your Laravel app

jQuery DataTables API for Laravel 4|5|6|7|8

jQuery DataTables API for Laravel 4|5|6|7|8 This package is created to handle server-side works of DataTables jQuery Plugin via AJAX option by using E

Laravel Datatables Package Demo App

#Laravel Datatables Demo App Datatables Package for Laravel 4|5 This package is created to handle server-side works of DataTables jQuery Plugin via AJ

Server-side handler of DataTables Jquery Plugin for Laravel 4

Project is not being maintained actively. You will most likely find a better more actively maintained fork here https://github.com/yajra/laravel-datat

This package was created to deal with laravel datatables and cruds using vuejs.
This package was created to deal with laravel datatables and cruds using vuejs.

datatable-cruds Installation This package was created to deal with laravel datatables and cruds using vuejs. Install the package through Composer. Run

DataTables server-side for CodeIgniter, supported both for CodeIgniter 3 and CodeIgniter 4.

CodeIgniter DataTables DataTables server-side for CodeIgniter, supported both for CodeIgniter 3 and CodeIgniter 4. Note: This library only handle the

Owner
Amir Rami
Amir Rami
Laravel-comments-livewire - Livewire components for the laravel-comments package

Associate comments and reactions with Eloquent models This package contains Livewire components to be used with the spatie/laravel-comments package. S

Spatie 15 Jan 18, 2022
Laravel 8 + CoreUI + Livewire + Datatables (CRUD)

Laravel 8 + CoreUI + Livewire + Datatables About Laravel 8 + CoreUI + Livewire Datatables Whats Inside Laravel Core UI - (https://github.com/HZ-HBO-IC

Muhammad Rheza Alfin 38 Nov 3, 2022
Laravel 8 + CoreUI + Livewire + Datatables (CRUD)

Laravel 8 + CoreUI + Livewire + Datatables About Laravel 8 + CoreUI + Livewire Datatables Whats Inside Laravel Core UI - (https://github.com/HZ-HBO-IC

Muhammad Rheza Alfin 38 Nov 3, 2022
⚡ PowerGrid generates Advanced Datatables using Laravel Livewire.

?? Documentation | ?? Features | ⌨️ Get started Livewire ⚡ PowerGrid ⚡ PowerGrid creates modern, powerful and easy to customize Datatables based on La

Power Components ⚡ 962 Jan 2, 2023
Projeto do Challange Back End Da Alura. Mais Detalhes no Site Oficial da Alura

Alura Challange BackEnd Projeto do Challange Back End Da Alura. Mais Detalhes no Site Oficial da Alura! Sobre o desafio Uma Aplicação (API REST) para

DinoDev 3 Jan 21, 2022
Easy Laravel Server-Side implementation of PrimeVue Datatables

Laravel + PrimeVue Datatables This is a simple, clean and fluent serve-side implementation of PrimeVue Datatables in Laravel. Features Global Search i

Savannabits 11 Dec 29, 2022
Laravel Dusk provides simple end-to-end testing and browser automation.

Introduction Laravel Dusk provides an expressive, easy-to-use browser automation and testing API. By default, Dusk does not require you to install JDK

The Laravel Framework 1.7k Jan 5, 2023
Auto generate routes for Laravel Livewire components

livewire-auto-routes Auto generate routes for Laravel Livewire Components. Requirements Livewire 2 Laravel 8 php 8 Installation composer require tanth

Tina Hammar 19 May 11, 2022
Laravel Livewire (TALL-stack) form generator with realtime validation, file uploads, array fields, blade form input components and more.

TALL-stack form generator Laravel Livewire, Tailwind forms with auto-generated views. Support Contributions Features This is not an admin panel genera

TinaH 622 Jan 2, 2023
Livewire UI components with tailwind base style

WireUI ?? Documentation Wire UI is a library of components and resources to empower your Laravel and Livewire application development. Starting a new

WireUi 811 Jan 2, 2023