Laravel Livewire Tables Documentation

🎉 Enjoying this package? Consider sponsoring me on GitHub or buying me a beer.

This is the documentation for v1 but the latest version is v3. You can switch versions in the menu at the top. Check your current version with the following command:

composer show rappasoft/laravel-livewire-tables

Built-in sorting

A column is either sortable or not.

Note: Sorting columns are stackable, if you would like only a single column to be sorted at a time, set the $singleColumnSorting class property to true.

For example:

1->orderBy('name', 'asc')->orderBy('email', 'desc')...

You can make a column sortable by adding the sortable() method to the column:

1Column::make('Type')
2 ->sortable()

If you would like more control over the sort behavior of a specific column, you may pass a closure:

1Column::make(__('Address'))
2 ->sortable(function(Builder $query, $direction) {
3 return $query->orderBy(UserAttribute::select('address')->whereColumn('user_attributes.user_id', 'users.id'), $direction);
4 })

To set the default sort order that gets overwritten when someone clicks a column header, you can use these class properties (Available in v1.8 and above):

1public string $defaultSortColumn = 'name';
2public string $defaultSortDirection = 'desc';