- 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
Text Filters
Text filters are just simple text filters, allowing you to pass a string value into a builder query.
1public function filters(): array 2{ 3 return [ 4 TextFilter::make('Name') 5 ->config([ 6 'placeholder' => 'Search Name', 7 'maxlength' => '25', 8 ]) 9 ->filter(function(Builder $builder, string $value) {10 $builder->where('users.name', 'like', '%'.$value.'%');11 }),12 ];13}
Extra Helpers
There are a number of helpers to simplify your code, should you not wish to rewrite the filter function repeatedly for a Text Filter. You can only use one of the below methods per-filter.
Contains
This executes the filter and returns results where the field contains the filter value
1public function filters(): array 2{ 3 return [ 4 TextFilter::make('Name') 5 ->config([ 6 'placeholder' => 'Search Name', 7 'maxlength' => '25', 8 ]) 9 ->contains('users.name'),10 ];11}
notContains
This executes the filter and returns results where the field does not contain filter value
1public function filters(): array 2{ 3 return [ 4 TextFilter::make('Name') 5 ->config([ 6 'placeholder' => 'Search Name', 7 'maxlength' => '25', 8 ]) 9 ->notContains('users.name'),10 ];11}
startsWith
This executes the filter and returns results where the field starts with the filter value
1public function filters(): array 2{ 3 return [ 4 TextFilter::make('Name') 5 ->config([ 6 'placeholder' => 'Search Name', 7 'maxlength' => '25', 8 ]) 9 ->startsWith('users.name'),10 ];11}
notStartsWith
This executes the filter and returns results where the field does not start with the filter value
1public function filters(): array 2{ 3 return [ 4 TextFilter::make('Name') 5 ->config([ 6 'placeholder' => 'Search Name', 7 'maxlength' => '25', 8 ]) 9 ->notStartsWith('users.name'),10 ];11}
endsWith
This executes the filter and returns results where the field ends with the filter value
1public function filters(): array 2{ 3 return [ 4 TextFilter::make('Name') 5 ->config([ 6 'placeholder' => 'Search Name', 7 'maxlength' => '25', 8 ]) 9 ->endsWith('users.name'),10 ];11}
notEndsWith
This executes the filter and returns results where the field does not end with the filter value
1public function filters(): array 2{ 3 return [ 4 TextFilter::make('Name') 5 ->config([ 6 'placeholder' => 'Search Name', 7 'maxlength' => '25', 8 ]) 9 ->notEndsWith('users.name'),10 ];11}
setFieldName
An optional method for setting the field to use when filtering, if used, you may omit the field from the above methods, for example:
1public function filters(): array 2{ 3 return [ 4 TextFilter::make('Name') 5 ->config([ 6 'placeholder' => 'Search Name', 7 'maxlength' => '25', 8 ]) 9 ->setFieldName('users.name')10 ->contains(),11 ];12}