DEV Community

Cover image for Your Laravel Queries Are Lying to You
Raheel Shan
Raheel Shan

Posted on • Originally published at raheelshan.com

Your Laravel Queries Are Lying to You

How many times does Product::latest() appear in your codebase?

If the answer is more than once, you're not DRY — you're just organized duplication. Every repeated query entry point is another interpretation of how that query should behave. Inconsistencies creep in silently, and future changes become a scavenger hunt.

Atomic Query Construction (AQC) fixes this with one rule:

Every model gets exactly one query entry point, inside a dedicated execution class.

// Every. Single. Time.
(new GetProducts())->handle($params);
Enter fullscreen mode Exit fullscreen mode

Filters, sorting, pagination — all controlled through params. One place to change, one place to debug, zero drift.

📖 Read the complete article here.

Top comments (0)