You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[](https://packagist.org/packages/rappasoft/laravel-livewire-tables)
* This defines the start of the query, usually Model::query() but can also eagar load relationships and counts.
79
+
*/
80
+
public function query() : Builder;
81
+
82
+
/**
83
+
* This defines the columns of the table, they don't necessarily have to map to columns on the table.
84
+
*/
85
+
public function columns() : array;
86
+
```
42
87
88
+
### Defining Columns
43
89
44
-
### Testing
90
+
You can define the columns of your table with the column class:
45
91
46
-
```bash
47
-
composer test
92
+
```
93
+
Column::make('Name', 'column_name')
94
+
```
95
+
96
+
The first parameter is the name of the table header. The second parameter is the name of the table column. You can leave blank and the lowercase snake_case version will be used by default.
97
+
98
+
Here are a list of the column method you can chain to build your columns:
99
+
100
+
```
101
+
/**
102
+
* This column is searchable, with no callback it will search the column by name or by the supplied relationship, using a callback overrides the default searching functionality.
103
+
*/
104
+
public function searchable(callable $callable = null) : self;
105
+
106
+
/**
107
+
* This column is sortable, with no callback it will sort the column by name and sort order defined on the components $sortDirection variable
108
+
*/
109
+
public function sortable(callable $callable = null) : self;
110
+
111
+
/**
112
+
* The columns output will be put through {!! !!} instead of {{ }}.
113
+
*/
114
+
public function unescaped() : self;
115
+
116
+
/**
117
+
* The columns output will be put through the Laravel HtmlString class.
118
+
*/
119
+
public function html() : self;
120
+
121
+
/**
122
+
* This column will not look on the table for the column name, it will look on the model for the given attribute. Useful for custom attributes like getFullNameAttribute: Column::make('Full Name', 'full_name')->customAttribute()
123
+
*/
124
+
public function customAttribute() : self;
125
+
126
+
/**
127
+
* This view will be used for the column, can still be used with sortable and searchable.
128
+
*/
129
+
public function view($view) : self;
130
+
```
131
+
132
+
### Properties
133
+
134
+
You can override any of these in your table component:
135
+
136
+
#### Table
137
+
138
+
| Property | Default | Usage |
139
+
| -------- | ------- | ----- |
140
+
| $tableHeaderEnabled | true | Whether or not to display the table header |
141
+
| $tableFooterEnabled | false | Whether or not to display the table footer |
142
+
| $tableClass | table table-striped | The class to set on the table |
143
+
| $tableHeaderClass |*none*| The class to set on the thead of the table |
144
+
| $tableFooterClass |*none*| The class to set on the tfoot of the table |
145
+
| $responsive | table-responsive | Tables wrapping div class |
146
+
147
+
#### Searching
148
+
149
+
| Property | Default | Usage |
150
+
| -------- | ------- | ----- |
151
+
| $searchEnabled | true | Whether or not searching is enabled |
152
+
| $searchDebounce | 350 | Amount of time in ms to wait to send the search query and refresh the table |
153
+
| $disableSearchOnLoading | true | Whether or not to disable the search bar when it is searching/loading new data |
154
+
| $search |*none*| The initial search string |
155
+
| $searchLabel | Search... | The placeholder for the search box |
156
+
| $noResultsMessage | There are no results to display for this query. | The message to display when there are no results |
157
+
158
+
#### Sorting
159
+
160
+
| Property | Default | Usage |
161
+
| -------- | ------- | ----- |
162
+
| $sortField | id | The initial field to be sorting by |
163
+
| $sortDirection | asc | The initial direction to sort |
164
+
165
+
#### Pagination
166
+
167
+
| Property | Default | Usage |
168
+
| -------- | ------- | ----- |
169
+
| $paginationEnabled | true | Displays per page and pagination links |
170
+
| $perPageOptions |[10, 25, 50]| The options to limit the amount of results per page |
171
+
| $perPage | 25 | Amount of items to show per page |
172
+
| $perPageLabel | Per Page | The label for the per page filter |
173
+
174
+
#### Loading
175
+
176
+
| Property | Default | Usage |
177
+
| -------- | ------- | ----- |
178
+
| $loadingIndicator | false | Whether or not to show a loading indicator when searching |
179
+
| $loadingMessage | Loading... | The loading message that gets displayed |
180
+
181
+
#### Offline
182
+
183
+
| Property | Default | Usage |
184
+
| -------- | ------- | ----- |
185
+
| $offlineIndicator | true | Whether or not to display an offline message when there is no connection |
186
+
| $offlineMessage | You are not currently connected to the internet. | The message to display when offline |
187
+
188
+
#### Checkboxes
189
+
190
+
| Property | Default | Usage |
191
+
| -------- | ------- | ----- |
192
+
| $checkbox | false | Whether or not checkboxes are enabled |
193
+
| $checkboxLocation | left | The side to put the checkboxes on |
194
+
| $checkboxAttribute | id | The model attribute to bind to the checkbox array |
195
+
| $checkboxAll | false | Whether or not all checkboxes are currently selected |
196
+
| $checkboxValues |[]| The currently selected values of the checkboxes |
197
+
198
+
#### Other
199
+
200
+
| Property | Default | Usage |
201
+
| -------- | ------- | ----- |
202
+
| $wrapperClass |*none*| The classes applied to the wrapper div |
203
+
| $refresh | false | Whether or not to refresh the table at a certain interval. false = off, If it's an integer it will be treated as milliseconds (2000 = refresh every 2 seconds), If it's a string it will call that function every 5 seconds.
204
+
205
+
### Table Methods
206
+
207
+
```
208
+
/**
209
+
* Used to set a class on a table header based on the column attribute
210
+
*/
211
+
public function thClass($attribute) : ?string;
212
+
213
+
/**
214
+
* Used to set a class on a table row
215
+
* You have the entre model of the row to work with
216
+
*/
217
+
public function trClass($model) : ?string;
218
+
219
+
/**
220
+
* Used to set the class of a table cell based on the column and the value of the cell
221
+
*/
222
+
public function tdClass($attribute, $value) : ?string;
48
223
```
49
224
50
-
###Changelog
225
+
## Changelog
51
226
52
227
Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.
0 commit comments