---
title: "Defining a Dedicated Query Builder in Laravel 12 With PHP Attributes"
url: https://daily.dev/posts/defining-a-dedicated-query-builder-in-laravel-12-with-php-attributes-s19dru9qi
source_url: https://laravel-news.com/defining-a-dedicated-query-builder-in-laravel-12-with-php-attributes
type: article
source: "Laravel News"
published: 2025-06-25T12:52:33.848Z
updated: 2025-06-25T12:52:54.825Z
tags: ["database", "php", "laravel"]
reading_time: 2
upvotes: 30
comments: 2
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.

# Defining a Dedicated Query Builder in Laravel 12 With PHP Attributes

**[Laravel News](https://daily.dev/sources/ln)** · 2 min read · 30 upvotes · 2 comments

## Summary

Laravel 12.19 introduces the UseEloquentBuilder PHP attribute as a cleaner way to define custom query builders for Eloquent models. Instead of overriding the newEloquentBuilder() method, developers can now use this attribute to specify a custom builder class. Custom query builders help organize model scopes, reduce model bloat, and provide reusable query methods. The custom builder class must extend Laravel's Builder class and can include methods like wherePublished() for common query patterns.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://laravel-news.com/defining-a-dedicated-query-builder-in-laravel-12-with-php-attributes>

## Community discussion

Top comments from developers on daily.dev.

**@kdavid** · 0 upvotes

> been cool seeing steady progress - it adds up. you think the best improvements in code come more from small refactors like this or from bigger rewrites?

## Similar posts on daily.dev

- [Don’t just attend KubeCon \+ CloudNativeCon, Merge Forward your experience\!](https://daily.dev/posts/don-t-just-attend-kubecon-cloudnativecon-merge-forward-your-experience--l0rpp73x8) · CNCF · 0 upvotes · 0 comments
- [Announcing H2 2026 KCDs](https://daily.dev/posts/announcing-h2-2026-kcds-m96goajm1) · CNCF · 1 upvotes · 0 comments
- [Two months of Open Community Groups](https://daily.dev/posts/two-months-of-open-community-groups-asf52zhbs) · CNCF · 0 upvotes · 0 comments
- [CNCF Unveils Schedule for KubeCon \+ CloudNativeCon Europe 2026](https://daily.dev/posts/cncf-unveils-schedule-for-kubecon-cloudnativecon-europe-2026-ikhcoa5cb) · CNCF · 2 upvotes · 0 comments
- [CNCF Debuts KubeCon \+ CloudNativeCon Japan 2026 Schedule](https://daily.dev/posts/cncf-debuts-kubecon-cloudnativecon-japan-2026-schedule-xp5pyudub) · CNCF · 1 upvotes · 0 comments

---

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

[View this post on daily.dev](https://daily.dev/posts/defining-a-dedicated-query-builder-in-laravel-12-with-php-attributes-s19dru9qi)
