Getting Started
Usage
DataTable
Columns
Rows
Sorting
Pagination
Search
Bulk Actions
Filters
Reordering
Secondary Header
Footer
Examples
Misc.
Sponsored
Advanced Usage
Examples
🎉 Enjoying this package? Considersponsoring me on GitHub orbuying me a beer.
This is the documentation forv2 but the latest version isv4. You can switch versions in the menuon the left/at the top. Check your current version with the following command:
composer show rappasoft/laravel-livewire-tablesCreating Columns
Thecolumns method on your component must return an array of Column objects in the order you wish to see them on the table:
1publicfunctioncolumns():array2{3return[4Column::make('Name'),5Column::make('Email'),6];7}Setting field names
By default, you only need one parameter which acts as the header of the column, the field which it references will be acquired usingStr::snake.
So if you have:
1publicfunctioncolumns():array2{3return[4Column::make('Name'),// Looks for column `name`5Column::make('Email'),// Looks for column `email`6];7}Of course, this won't work in every situation, for example if you have an ID column, Str::snake will convert it toi_d which is incorrect. For this situation and any other situation where you want to specify the field name, you can pass it as the second parameter:
1publicfunctioncolumns():array2{3return[4Column::make('ID','id'),5Column::make('E-mail','email'),6];7}