rappasoft/laravel-livewire-tables
Laravel Livewire Tables provides dynamic, feature-rich data tables for Laravel Livewire with sorting, searching, filtering, pagination, bulk actions, and Bootstrap/Tailwind support. Build reusable table components backed by Eloquent queries.
You can create components by using the command or copying from one of the examples.
This is what a bare bones component looks like before your customization:
<?php
namespace App\Livewire;
use App\Models\User;
use Rappasoft\LaravelLivewireTables\DataTableComponent;
use Rappasoft\LaravelLivewireTables\Views\Column;
class UsersTable extends DataTableComponent
{
protected $model = User::class;
public function configure(): void
{
$this->setPrimaryKey('id');
}
public function columns(): array
{
return [
Column::make('ID', 'id')
->sortable(),
Column::make('Name')
->sortable(),
];
}
}
Your component will extend the Rappasoft\LaravelLivewireTables\DataTableComponent class and at minimum implement 2 methods called configure and columns.
To use a Table as a Full Page Component, there are a few options that you must set in your configure() method.
To use a Custom Layout (as a Full Page Component), use the setLayout() method, which expects to be passed a string which is the path to the layout.
public function configure(): void
{
$this->setLayout('path-to-layout');
}
To use a Custom Slot (as a Full Page Component), use setSlot() method, which expects to be passed a string which is the name of the slot.
public function configure(): void
{
$this->setSlot('slot-name-here');
}
To use a Custom Section (as a Full Page Component), use setSection() method, which expects to be passed a string which is the name of the section.
<?php
namespace App\Livewire;
use App\Models\User;
use Rappasoft\LaravelLivewireTables\DataTableComponent;
use Rappasoft\LaravelLivewireTables\Views\Column;
class UsersTable extends DataTableComponent
{
protected $model = User::class;
public function configure(): void
{
$this->setPrimaryKey('id')
->setLayout('path-to-layout')
->setSlot('slot-name-here');
}
public function columns(): array
{
return [
Column::make('ID', 'id')
->sortable(),
Column::make('Name')
->sortable(),
];
}
}
How can I help you explore Laravel packages today?