- Creating Columns
- Relationships
- Available Methods
- Other Column Types
- Column Selection
- Secondary Header
- Footer
- Reusable Columns
- Anonymous Columns
- Introduction
- Date Filters
- DateRange Filters
- DateTime Filters
- Multi-Select Dropdown Filters
- Multi-Select Filters
- NumberRange Filters
- Number Filters
- Select Filters
- Text Filters
- Refreshing
- Loading Placeholder
- Multiple Tables Same Page
- Adding Custom Markup
- Debugging
- Saving Table State
- Lifecycle Hooks
Getting Started
Usage
DataTable
Columns
Rows
Sorting
Pagination
Search
Bulk Actions
Filters
Filter Types
Reordering
Secondary Header
Footer
Examples
Misc.
Sponsored
Advanced Usage
Examples
🎉 Enjoying this package? Consider sponsoring me on GitHub or buying me a beer.
This is the documentation for v3. You can switch versions in the menu on the left/at the top. Check your current version with the following command:
composer show rappasoft/laravel-livewire-tables
Creating Columns
The columns
method on your component must return an array of Column objects in the order you wish to see them on the table:
1public function columns(): array2{3 return [4 Column::make('Name'),5 Column::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 using Str::snake
.
So if you have:
1public function columns(): array2{3 return [4 Column::make('Name'), // Looks for column `name`5 Column::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 to i_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:
1public function columns(): array2{3 return [4 Column::make('ID', 'id'),5 Column::make('E-mail', 'email'),6 ];7}