Repository navigation
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add a centralized pagination policy for filtered queries while preserving Laravel's familiar
paginate(),simplePaginate(), andcursorPaginate()APIs.Problem
Filterable previously forwarded pagination calls directly to Eloquent and exposed a legacy
paginate_limitsetting through the model trait. That behavior had several limitations:paginate(),simplePaginate(), andcursorPaginate()had no unified policy.What changed
Central pagination policy
Introduce
PaginationPolicyto resolve page sizes using this priority:$perPageargument;Every resolved value remains subject to the effective maximum.
Laravel-compatible pagination calls
The existing API remains unchanged:
Explicit arguments still take precedence over request input:
If the effective maximum is
100,paginate(500)is clamped to100or rejected according to the configured overflow behavior.Global configuration
Supported overflow modes:
clamp: cap oversized values at the configured maximum;reject: throwInvalidPageSizeException.Malformed, zero, and negative page sizes are rejected in both modes.
The legacy
paginate_limitvalue remains supported as the default when an application still uses an older published configuration.Filter-level and runtime overrides
A filter class can define a reusable policy:
Endpoints can override selected values at runtime:
Runtime settings override filter-class settings, which override package configuration. Omitted values continue to inherit.
Raw builder behavior
Pagination called directly on a Filterable instance still applies the policy when
shouldReturnQueryBuilder()is enabled:An Eloquent builder obtained through an explicit
apply()call is intentionally outside Filterable's execution boundary:Direct Eloquent queries that do not pass through
filter()are also unchanged.Compatibility details
$perPagevalues accepted bypaginate();Invokeris serialized;Documentation
Tests
Coverage includes:
paginate()closures;shouldReturnQueryBuilder()behavior;