Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move default pagination to 20, 50, 100, all #1400

Merged
merged 10 commits into from
Mar 11, 2024
1 change: 0 additions & 1 deletion packages/admin/src/Filament/Resources/OrderResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ public static function getDefaultTable(Table $table): Table
])
->filters(static::getTableFilters())
->defaultSort('id', 'DESC')
->paginated([10, 25, 50, 100])
->selectCurrentPageOnly()
->deferLoading()
->poll('60s');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,6 @@ public function getTabs(): array
];
}

protected function paginateTableQuery(Builder $query): Paginator
{
return $query->simplePaginate($this->getTableRecordsPerPage());
}

public function getMaxContentWidth(): MaxWidth
{
return MaxWidth::Full;
Expand Down
7 changes: 7 additions & 0 deletions packages/admin/src/LunarPanelManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Filament\Support\Colors\Color;
use Filament\Support\Facades\FilamentColor;
use Filament\Support\Facades\FilamentIcon;
use Filament\Tables\Table;
use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse;
use Illuminate\Cookie\Middleware\EncryptCookies;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken;
Expand Down Expand Up @@ -143,6 +144,12 @@ public function register(): self
'chartSecondary' => Color::Green,
]);

Table::configureUsing(function (Table $table): void {
$table
->paginationPageOptions([10, 25, 50, 100])
->defaultPaginationPageOption(25);
});

return $this;
}

Expand Down
6 changes: 6 additions & 0 deletions packages/admin/src/Support/Pages/BaseListRecords.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Lunar\Admin\Support\Pages;

use Filament\Resources\Pages\ListRecords;
use Illuminate\Contracts\Pagination\Paginator;
use Illuminate\Database\Eloquent\Builder;
use Lunar\Base\Traits\Searchable;

Expand Down Expand Up @@ -49,4 +50,9 @@ protected function applySearchToTableQuery(Builder $query): Builder

return $query;
}

protected function paginateTableQuery(Builder $query): Paginator
{
return $query->paginate($this->getTableRecordsPerPage());
}
}
Loading