Laravel Livewire Tables Documentation

🎉 Enjoying this package? Consider sponsoring me on GitHub or buying me a beer.

This is the documentation for v1 but the latest version is v3. You can switch versions in the menu at the top. Check your current version with the following command:

composer show rappasoft/laravel-livewire-tables

Basic Example

At the very least, you need to give the DataTable component a list of columns and a base query to start with:

For this basic example, the component will use the columns to generate the display as well, it will also use the columns sortable() and searchable() methods to add that functionality for you automatically.

1<?php
2 
3namespace App\Http\Livewire\Admin\User;
4 
5use App\Domains\Auth\Models\User;
6use Illuminate\Database\Eloquent\Builder;
7use Rappasoft\LaravelLivewireTables\DataTableComponent;
8use Rappasoft\LaravelLivewireTables\Views\Column;
9 
10class UsersTable extends DataTableComponent
11{
12 
13 public function columns(): array
14 {
15 return [
16 Column::make('Name')
17 ->sortable()
18 ->searchable(),
19 Column::make('E-mail', 'email')
20 ->sortable()
21 ->searchable(),
22 Column::make('Verified', 'email_verified_at')
23 ->sortable(),
24 ];
25 }
26 
27 public function query(): Builder
28 {
29 return User::query();
30 }
31}