Create Tables for Your Models with Livewire Tables

Published on by

Create Tables for Your Models with Livewire Tables image

The Livewire Tables package brings dynamic tables for models to Laravel Livewire. These are some of the highlights which you will get out of the box:

  • Selection of the columns you wish to see
  • Apply multiple filters at the same time
  • Perform actions on the selected records
  • Works perfectly with the SoftDeletes trait
  • Search columns individually
  • Multiple column types supported
  • Dark mode support
  • 100% code coverage

It works by creating your table component that extends from the base LivewireTable component like the following example:

namespace App\Livewire;
 
use RamonRietdijk\LivewireTables\Livewire\LivewireTable;
 
class BlogTable extends LivewireTable
{
protected string $model = Blog::class;
}

Without repeating the documentation, here's an example of how you can map table columns to a model column:

// Normal column
Column::make(__('Name'), 'name'),
 
// A boolean column
BooleanColumn::make(__('Published'), 'published'),
 
// A date-based column
DateColumn::make(__('Created At'), 'created_at')
->format('d m Y'),

There are various other types of columns that you can reference in the Columns documentation. Besides columns, you can also define filters, column actions, and more.

To render a table component like we have in our example, you can write the following:

<livewire:blog-table/>

You can start with this package by checking out the Documentation, starting with the Introduction to Livewire Tables. There's also a demo available if you want to see it in action before you dive in! Lastly, you can see the source code on GitHub at ramonrietdijk/livewire-tables.

Paul Redmond photo

Staff writer at Laravel News. Full stack web developer and author.

Cube

Laravel Newsletter

Join 40k+ other developers and never miss out on new tips, tutorials, and more.

image
No Compromises

Joel and Aaron, the two seasoned devs from the No Compromises podcast, are now available to hire for your Laravel project.

Visit No Compromises
Laravel Forge logo

Laravel Forge

Easily create and manage your servers and deploy your Laravel applications in seconds.

Laravel Forge
Tinkerwell logo

Tinkerwell

The must-have code runner for Laravel developers. Tinker with AI, autocompletion and instant feedback on local and production environments.

Tinkerwell
No Compromises logo

No Compromises

Joel and Aaron, the two seasoned devs from the No Compromises podcast, are now available to hire for your Laravel project. ⬧ Flat rate of $7500/mo. ⬧ No lengthy sales process. ⬧ No contracts. ⬧ 100% money back guarantee.

No Compromises
Kirschbaum logo

Kirschbaum

Providing innovation and stability to ensure your web application succeeds.

Kirschbaum
Shift logo

Shift

Running an old Laravel version? Instant, automated Laravel upgrades and code modernization to keep your applications fresh.

Shift
LoadForge logo

LoadForge

Easy, affordable load testing and stress tests for websites, APIs and databases.

LoadForge
Paragraph logo

Paragraph

Manage your Laravel app as if it was a CMS – edit any text on any page or in any email without touching Blade or language files.

Paragraph
Lucky Media logo

Lucky Media

Bespoke software solutions built for your business. We ♥ Laravel

Lucky Media
Lunar: Laravel E-Commerce logo

Lunar: Laravel E-Commerce

E-Commerce for Laravel. An open-source package that brings the power of modern headless e-commerce functionality to Laravel.

Lunar: Laravel E-Commerce
Bacancy - Staff Augmentation logo

Bacancy - Staff Augmentation

Leave your web app development hustles to the leading IT Staff Augmentation Service Providers. Choose from an extensive pool of 1050+ developers and give yourself the sigh of success you deserve with Bacancy. Get In Touch Today!

Bacancy - Staff Augmentation
DocuWriter.ai logo

DocuWriter.ai

Save hours of manually writing Code Documentation, Comments & DocBlocks, Test suites and Refactoring.

DocuWriter.ai
Rector logo

Rector

Your partner for seamless Laravel upgrades, cutting costs, and accelerating innovation for successful companies

Rector

The latest

View all →
Add Architecture Tests to Saloon API Integrations with Lawman image

Add Architecture Tests to Saloon API Integrations with Lawman

Read article
Protect Routes with JWT Tokens Using This Package for Laravel image

Protect Routes with JWT Tokens Using This Package for Laravel

Read article
Increment a Rate Limiter by a Custom Amount in Laravel 10.46 image

Increment a Rate Limiter by a Custom Amount in Laravel 10.46

Read article
Add Kanban Boards to Your Laravel App in Seconds image

Add Kanban Boards to Your Laravel App in Seconds

Read article
October CMS v3.6 Ships Today, Full of New Features image

October CMS v3.6 Ships Today, Full of New Features

Read article
Laracon EU Videos are now out image

Laracon EU Videos are now out

Read article