Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Laravel Query Strategies

Laravel Query Strategies Laravel Package

myerscode/laravel-query-strategies

myerscode/laravel-query-strategies provides reusable, composable query strategies for Laravel Eloquent models, helping you encapsulate filtering, sorting, and search logic to keep controllers clean and queries testable.

View on GitHub
Deep Wiki
Context7

A package for applying filters, ordering, eager loads, result limiting and pagination to Eloquent queries

Frequently asked questions about Laravel Query Strategies
What is myerscode/laravel-query-strategies used for in Laravel?
It provides reusable, composable query strategy classes for Eloquent models in Laravel. You define named strategies that map HTTP query parameters to filters, sorts, eager loads, field selection, limits, and pagination. This keeps controllers thin and moves list-endpoint query logic into testable, versionable classes.
How do I install and configure myerscode/laravel-query-strategies?
Install it with Composer using composer require myerscode/laravel-query-strategies, then publish the package config if you need to customise defaults. The package follows Laravel's conventional service-provider discovery and config-publish flow. Pin an exact version such as 13.0.* until you have reviewed the changelog for your application.
Which Laravel and PHP versions does this package support?
Version 13.0.0 targets Laravel 13 and Testbench 11, so adoption is effectively gated on running Laravel 13. The release likely drops support for earlier Laravel and PHP versions, but you should confirm the exact illuminate/* and PHP constraints in composer.json. If you are on Laravel 11 or 12, do not assume a compatible upgrade path without checking for a maintenance branch.
Can I filter and sort by relationships with this package?
Yes, the 13.0.0 feature set includes relationship filtering, nested relationship sorting, and aggregate relationship includes. That covers most realistic list-endpoint requirements without bespoke query code. You still need to design which relationships are exposed and validate them, especially if input comes from API clients.
Why use query strategies instead of ->when() filters in my controller?
Ad-hoc ->when($request->has(...)) calls are fine for one endpoint but become duplicated and hard to test across many endpoints. Strategies centralise that logic into named, reusable classes that can be unit-tested and treated as documented API contracts. The tradeoff is a new vocabulary and abstraction layer, so it fits best when you have many list endpoints or a public or partner API surface.
Does the package support strict mode for safe query input?
Strict mode is an opt-in safety control for validating query input and should be treated as a security feature, not just convenience. The 13.0.0 release adds strict mode and fixes eager-load validation, so input that was previously accepted, ignored, or exploited may now behave differently. You should enable it deliberately and confirm per-strategy overrides or escape hatches in the documentation before exposing strategies to untrusted clients.
What breaking changes should I expect when upgrading to 13.0.0?
The jump from 12.x to 13.0.0 is a major release and almost certainly includes breaking changes, including readonly Parameter objects and internal StrategyManager changes. That can break custom strategies or parameters that mutate state after construction. Read the changelog end-to-end and look for an upgrade guide, as a definitive public breaking-change list should be confirmed from the project.
Can I extend the package with custom clauses, strategies, or parameters?
The package is designed around strategies, parameters, and clauses, and 13.0.0 adds ScopeClause, TrashedClause, and BetweenClause for common needs. Custom clause classes are possible in principle, but the readonly Parameter conversion and StrategyManager refactor tightened internal contracts. Confirm the documented extension contract before relying on custom internals in production.
How do I test my Laravel query strategies?
Because strategies encapsulate query logic in classes, you can test them directly without going through HTTP. Cover the compiled query behaviour, allowed parameters, strict-mode rejection cases, and pagination or limit output. Laravel's query builder assertions or database assertions work well here, and Testbench 11 support aligns the package with Laravel 13 testing.
Is myerscode/laravel-query-strategies production-ready and actively maintained?
Treat it as production-capable but moderate-risk: 13.0.0 has strong engineering signals such as improved test coverage, Rector modernisation, and Larastan level 8 compliance, but it is a major jump with no prior assessment. Adopt it in a non-critical service first, pin 13.0.*, and review the changelog. Maintainer bus factor and release cadence are not established by the available information, so those are worth checking on the repository.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
robertmarney/lara-hierarchial-collections
simonschaufi/rule-doc-generator
emissaoja/emissaoja
blackbricksoftware/gravityforms-civicrm-form-processor
al-rahabi/fancy-crud
jinas/dhivatar-component
mltstephane/laravel-quality
bernskiold/laravel-talentlms
bernskioldmedia/laravel-form-architect
youbar/easy-crud
c-point-labs/laravel-hostyourai
dbravoan/dbcms-admin-theme-dbcms
dbravoan/dbcms-theme-db-cyber
dbravoan/dbcms-blocks-basic
dbravoan/dbcms-module-content-audit
dbravoan/dbcms-module-ai-assistant
paygate-to/paygate-php
padosoft/askmydocs-connector-base
defstudio/supercharged-carbon
bernskioldmedia/laravel-matomo