---
title: "Eloquent Query Classes Pattern"
url: https://daily.dev/posts/eloquent-query-classes-pattern-fxd2vu1ki
source_url: https://wendelladriel.com/blog/eloquent-query-classes-pattern
type: article
source: "W endell Adriel"
author: "Wendell Adriel"
published: 2026-06-08T13:09:46.898Z
updated: 2026-06-09T10:00:12.599Z
tags: ["php", "laravel"]
reading_time: 16
upvotes: 41
comments: 8
language: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Eloquent Query Classes Pattern

**[W endell Adriel](https://daily.dev/sources/wendelladriel)** · [@wendell_adriel](https://daily.dev/wendell_adriel) · 16 min read · 41 upvotes · 8 comments

## Summary

The Eloquent Query Classes pattern organizes complex or reusable database queries in Laravel by wrapping them in small, focused classes with a single `handle()` method. Unlike the Repository Pattern, these classes don't abstract away Eloquent — they give important business queries a dedicated name and home. The post covers when to use query classes vs. local scopes, how to structure them in small and large apps, whether to return a Builder or execute the query directly, how to handle write operations, and how to test them with Pest and database factories. Practical guidelines include naming classes after business questions, keeping only one public method, and avoiding over-abstraction.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://wendelladriel.com/blog/eloquent-query-classes-pattern>

## Community discussion

Top comments from developers on daily.dev.

**@hadilbenabdallah** · 1 upvotes

> Good strategy.

**@josesoaresifthenpay** · 0 upvotes

> Wouldn't it be ok to just add those queries in the model itself?
> I imagine that if I have a bunch of models and a bunch more queries for those models, I'd end up with some unmanageable amount of files.

**@ax\_prashant** · 0 upvotes

> ![GIF](https://static.klipy.com/ii/d6b0ce929193df3c242ac34b5654d2ce/b9/aa/Z2uKHvgg.gif)

**@tanvirshaikh** · 0 upvotes

> I had the same issue. Some complex queries were repeated in multiple controllers, so I made a common method, but your approach is much cleaner. I’ll try using this. Thanks 🔥🔥

**@raziul** · 0 upvotes

> This is a very good approach to separate the queries, I prefer to use static make method instead of handle. eg: RelatedProductQuery::make()

---

Tags: [#php](https://daily.dev/tags/php), [#laravel](https://daily.dev/tags/laravel)

[View this post on daily.dev](https://daily.dev/posts/eloquent-query-classes-pattern-fxd2vu1ki)
