- Creating Columns
- Relationships
- Available Methods
- Other Column Types
- Column Selection
- Secondary Header
- Footer
- Reusable Columns
- Anonymous Columns
- Styling
- Standard Column
- Array Columns (beta)
- Avg Columns (beta)
- Boolean Columns
- Button Group Columns
- Color Columns
- Component Columns
- Count Columns (beta)
- Date Columns
- Icon Columns (beta)
- Image Columns
- Increment Column (beta)
- Link Columns
- Livewire Component (beta)
- Sum Columns (beta)
- View Component Columns
- Wire Link Column (beta)
- Introduction
- Creating Filters
- Applying Filters
- Available Methods
- Available Component Methods
- Available Filter Methods
- Introduction
- Boolean Filters (beta)
- Date Filters
- DateRange Filters
- DateTime Filters
- Multi-Select Dropdown Filters
- Multi-Select Filters
- NumberRange Filters
- Number Filters
- Select Filters
- Text Filters
- Livewire Custom Filter (Beta)
- Refreshing
- Loading Placeholder
- Multiple Tables Same Page
- Actions (beta)
- Adding Custom Markup
- Debugging
- Saving Table State
- Lifecycle Hooks
- Hiding The Table (beta)
- One Of Many Example
- Tools
Getting Started
Usage
DataTable
Columns
Column Types
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}