Skip to content

Commit 03c6f03

Browse files
committed
Allow per page customization
1 parent 9c34730 commit 03c6f03

File tree

6 files changed

+14
-10
lines changed

6 files changed

+14
-10
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ All notable changes to `laravel-livewire-tables` will be documented in this file
1212

1313
- Clarified where rowView looks in read me
1414
- Null the search filter when it's empty
15+
- Fill per page options from $perPageAccepted in views
16+
- Make $perPageAccepted public
1517

1618
### Removed
1719

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,8 @@ There are some class level properties you can set:
404404
| $showPagination | true | bool | Show the pagination when pagination is enabled |
405405
| $showSorting | true | bool | Show the sorting pills |
406406
| $showFilters | true | bool | Show the filter pills |
407+
| $perPage | 10 | int | The default per page amount selected (must exist in list) |
408+
| $perPageAccepted | [10, 25, 50] | int[] | The values for the per page dropdown, in order |
407409
| $searchFilterDebounce | null | null/int | Adds a debounce of `$searchFilterDebounce` ms to the search input |
408410
| $searchFilterDefer | null | null/bool | Adds `.defer` to the search input |
409411
| $searchFilterLazy | null | null/bool | Adds `.lazy` to the search input |

resources/views/bootstrap-4/includes/per-page.blade.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
id="perPage"
66
class="form-control"
77
>
8-
<option value="10">10</option>
9-
<option value="25">25</option>
10-
<option value="50">50</option>
8+
@foreach ($perPageAccepted as $item)
9+
<option value="{{ $item }}">{{ $item }}</option>
10+
@endforeach
1111
</select>
1212
</div>
1313
@endif

resources/views/bootstrap-5/includes/per-page.blade.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
id="perPage"
66
class="form-select"
77
>
8-
<option value="10">10</option>
9-
<option value="25">25</option>
10-
<option value="50">50</option>
8+
@foreach ($perPageAccepted as $item)
9+
<option value="{{ $item }}">{{ $item }}</option>
10+
@endforeach
1111
</select>
1212
</div>
1313
@endif

resources/views/tailwind/includes/per-page.blade.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
id="perPage"
66
class="rounded-md shadow-sm block w-full pl-3 pr-10 py-2 text-base leading-6 border-gray-300 focus:outline-none focus:border-indigo-300 focus:shadow-outline-indigo sm:text-sm sm:leading-5"
77
>
8-
<option value="10">10</option>
9-
<option value="25">25</option>
10-
<option value="50">50</option>
8+
@foreach ($perPageAccepted as $item)
9+
<option value="{{ $item }}">{{ $item }}</option>
10+
@endforeach
1111
</select>
1212
</div>
1313
@endif

src/Traits/WithPerPagePagination.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ trait WithPerPagePagination
1111
public bool $showPerPage = true;
1212
public bool $showPagination = true;
1313
public int $perPage = 10;
14-
protected array $perPageAccepted = [10, 25, 50];
14+
public array $perPageAccepted = [10, 25, 50];
1515

1616
public function mountWithPerPagePagination(): void
1717
{

0 commit comments

Comments
 (0)