laravel-expansions/query-control-model
Query Control Model is a Laravel package that adds controllable query behaviour to Eloquent models, letting you define, restrict, and reuse model queries through clean, consistent APIs. It helps keep filtering and data access predictable across your application.
Architecture fit: The package is a thin convenience layer over Eloquent’s with() and withCount() APIs, likely adding support for comma-separated relation values. v1.0.2 is a patch release fixing an incorrect comma-explode implementation. It fits Laravel applications that dynamically compose relation strings or accept comma-separated input from config, requests, or admin tooling. Architectural footprint is low if implemented via builder macros or mixins, but risk increases if it overrides core Eloquent methods.
Integration feasibility: Composer-based installation is straightforward. Feasibility depends on Laravel/PHP version compatibility and whether the package conflicts with other Eloquent extensions. The patch itself is small and non-breaking, but it should be validated against nested relations, aliases, whitespace, empty values, and native array syntax.
Technical risk: Primary risk is behavioral divergence from native Eloquent semantics. The fixed bug suggests earlier versions could silently mis-parse comma-separated relations, leading to missing eager loads or incorrect withCount results. Additional risk exists around Eloquent method overriding, Octane compatibility, and upgrade safety. Require test coverage for comma-separated strings, arrays, nested relations, and withCount aliases.
Key questions: Does the package use macros or subclass Eloquent? Does it preserve native with()/withCount() behavior for arrays and strings? How does it handle nested relations such as posts.comments? Are whitespace, empty strings, and aliases handled correctly? What Laravel and PHP versions are supported? Is there CI coverage for the fixed behavior?
Stack fit: Best suited to Laravel applications already using or standardizing on comma-separated relation input. If the application consistently uses native arrays, the package adds little value and should not be adopted.
Migration path: Adopt v1.0.2 or later only; avoid earlier versions because of the comma-explode defect. Replace custom relation-string normalization helpers with the package only after adding regression tests that cover the same behavior.
Compatibility: Verify support for the application’s Laravel and PHP versions, and confirm compatibility with other packages that extend Eloquent. Test under Octane if used, since long-lived workers can expose state or macro-registration issues.
Sequencing: 1) Pin ^1.0.2 in Composer. 2) Add tests for comma-separated with/withCount, nested relations, arrays, whitespace, and empty values. 3) Run in staging with query-count assertions. 4) Roll out to production with a documented fallback to native array syntax.
Maintenance: The package appears small and actively patched, but it is early-stage. Assign an internal owner and track upstream releases. Pin versions and review changelogs before upgrades.
Support: Likely community-supported with no vendor SLA. Internal documentation should state supported syntax and escalation paths.
Scaling: Runtime overhead should be negligible if the package only normalizes arguments. Monitor for incorrect relation parsing that could cause missing eager loads, extra queries, or N+1 behavior.
Failure modes: Incorrect comma handling, silent relation omission, conflicts with other Eloquent extensions, breakage on Laravel upgrades, and unexpected behavior under Octane. Add tests that assert both loaded relations and query counts.
Ramp-up: Low for Laravel developers, but the package’s syntax and edge cases must be documented. Provide examples for arrays, comma-separated strings, nested relations, and withCount aliases.
How can I help you explore Laravel packages today?