Laravel Livewire Tables Documentation

🎉 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 at the top. Check your current version with the following command:

composer show rappasoft/laravel-livewire-tables

Available Methods

These are the available configuration methods on the datatable component.

General

setPrimaryKey

Set the primary key column of the component.

1public function configure(): void
2{
3 $this->setPrimaryKey('id');
4}

Attributes

Documentation for Data Table Styling/Attributes is now: Here

Offline

Offline indicator is enabled by default, but if you ever needed to toggle it you can use the following methods:

Enable/disable the offline indicator.

setOfflineIndicatorStatus

1public function configure(): void
2{
3 $this->setOfflineIndicatorStatus(true);
4 $this->setOfflineIndicatorStatus(false);
5}

setOfflineIndicatorEnabled

Enable the offline indicator.

1public function configure(): void
2{
3 // Shorthand for $this->setOfflineIndicatorStatus(true)
4 $this->setOfflineIndicatorEnabled();
5}

setOfflineIndicatorDisabled

Disable the offline indicator.

1public function configure(): void
2{
3 // Shorthand for $this->setOfflineIndicatorStatus(false)
4 $this->setOfflineIndicatorDisabled();
5}

Query String

The query string is enabled by default, but if you ever needed to toggle it you can use the following methods:

setQueryStringStatus

Enable/disable the query string.

1public function configure(): void
2{
3 $this->setQueryStringStatus(true);
4 $this->setQueryStringStatus(false);
5}

setQueryStringEnabled

Enable the query string.

1public function configure(): void
2{
3 // Shorthand for $this->setQueryStringStatus(true)
4 $this->setQueryStringEnabled();
5}

setQueryStringDisabled

Disable the query string.

1public function configure(): void
2{
3 // Shorthand for $this->setQueryStringStatus(false)
4 $this->setQueryStringDisabled();
5}

Relationships

Disabled by default, enable to eager load relationships for all columns in the component.

setEagerLoadAllRelationsStatus

Enable/disable column relationship eager loading.

1public function configure(): void
2{
3 $this->setEagerLoadAllRelationsStatus(true);
4 $this->setEagerLoadAllRelationsStatus(false);
5}

setEagerLoadAllRelationsEnabled

Enable column relationship eager loading.

1public function configure(): void
2{
3 // Shorthand for $this->setEagerLoadAllRelationsStatus(true)
4 $this->setEagerLoadAllRelationsEnabled();
5}

setEagerLoadAllRelationsDisabled

Disable column relationship eager loading.

1public function configure(): void
2{
3 // Shorthand for $this->setEagerLoadAllRelationsStatus(false)
4 $this->setEagerLoadAllRelationsDisabled();
5}

Builder

setAdditionalSelects

By default the only columns defined in the select statement are the ones defined via columns. If you need to define additional selects that you don't have a column for you may:

Note - that you may only call this once, and it will override any existing additionalSelects in use.

1public function configure(): void
2{
3 $this->setAdditionalSelects(['users.id as id']);
4}

Since you probably won't have an ID column defined, the ID will not be available on the model to use. In the case of an actions column where you have buttons specific to the row, you probably need that, so you can add the select statement to make it available on the model.

addAdditionalSelects

By default the only columns defined in the select statement are the ones defined via columns. If you need to define additional selects that you don't have a column for you may:

Note - that in contrast to setAdditionalSelects, you may call this multipole times, and it will append the additional selects. Take care not to re-use the same field names!

1public function configure(): void
2{
3 $this->addAdditionalSelects(['users.id as id']);
4}

Misc.

setEmptyMessage

Set the message displayed when the table is filtered but there are no results to show.

Defaults to: "No items found. Try to broaden your search."

1public function configure(): void
2{
3 $this->setEmptyMessage('No results found');
4}