# eloquent

Published articles for eloquent.

This is one page of public article previews, not the complete archive. Follow Next page to continue. Summaries are not the original full articles.

## Eloquent Performance and Database Design: Evidence Before Eager Loading

DevFeed: [Eloquent Performance and Database Design: Evidence Before Eager Loading](<https://devfeed.tech/articles/eloquent-performance-and-database-design-evidence-before-eager-loading-33303.md>)

Original publisher: [Read original article](<https://freek.dev/3190-eloquent-performance-and-database-design-evidence-before-eager-loading>)

Author: Freek Van der Herten (freek@spatie.be)

Published: 2026-09-11T12:30:27Z

Content type: tutorial

Language: en

Sources: [freek.dev - all blogposts](<https://devfeed.tech/sources/freek-dev-all-blogposts.md>)

Topics: [Eloquent ORM](<https://devfeed.tech/topics/eloquent.md>), [Database](<https://devfeed.tech/topics/database.md>), [Laravel](<https://devfeed.tech/topics/laravel.md>), [PHP](<https://devfeed.tech/topics/php.md>)

Tags: [database](<https://devfeed.tech/tags/database.md>), [eager-loading](<https://devfeed.tech/tags/eager-loading.md>), [eloquent](<https://devfeed.tech/tags/eloquent.md>), [indexes](<https://devfeed.tech/tags/indexes.md>), [laravel](<https://devfeed.tech/tags/laravel.md>), [optimization](<https://devfeed.tech/tags/optimization.md>), [performance](<https://devfeed.tech/tags/performance.md>), [php](<https://devfeed.tech/tags/php.md>), [query](<https://devfeed.tech/tags/query.md>)

### AI overview

A practical deep dive into improving Eloquent performance and database design for a growing team dashboard. It covers detecting N+1 queries, choosing aggregates and indexes, inspecting query plans, pagination, chunking, and transaction boundaries.

### Source excerpt

A deep dive into Eloquent performance, from detecting N+1 queries to choosing aggregates, indexes, query plans, pagination, chunking, and transaction boundaries for a growing team dashboard. Read more

## How to create factories for models with polymorphic relationships in Laravel

DevFeed: [How to create factories for models with polymorphic relationships in Laravel](<https://devfeed.tech/articles/how-to-create-factories-for-models-with-polymorphic-relationships-in-laravel-37162.md>)

Original publisher: [Read original article](<https://arkadiuszchmura.com/posts/how-to-create-factories-for-models-with-polymorphic-relationships-in-laravel/>)

Published: 2023-03-29T00:00:00Z

Content type: tutorial

Language: en

Sources: [Arkadiusz Chmura](<https://devfeed.tech/sources/arkadiusz-chmura.md>)

Topics: [Laravel](<https://devfeed.tech/topics/laravel.md>), [Eloquent ORM](<https://devfeed.tech/topics/eloquent.md>), [Code](<https://devfeed.tech/topics/code.md>), [Database](<https://devfeed.tech/topics/database.md>)

Tags: [code](<https://devfeed.tech/tags/code.md>), [eloquent](<https://devfeed.tech/tags/eloquent.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [laravel](<https://devfeed.tech/tags/laravel.md>), [relationships](<https://devfeed.tech/tags/relationships.md>), [users](<https://devfeed.tech/tags/users.md>)

### AI overview

A Laravel tutorial explaining how to build model factories for polymorphic relationships, including custom morph aliases and factory states for associating different related models.

### Source excerpt

Factories for these models are a bit trickier to implement than the standard ones.

## Querying and Eager Loading complex relations in Laravel

DevFeed: [Querying and Eager Loading complex relations in Laravel](<https://devfeed.tech/articles/querying-and-eager-loading-complex-relations-in-laravel-39019.md>)

Original publisher: [Read original article](<https://blog.jgrossi.com/2018/querying-and-eager-loading-complex-relations-in-laravel/>)

Author: Junior Grossi

Published: 2018-05-07T08:00:12Z

Content type: tutorial

Language: en

Sources: [Junior Grossi](<https://devfeed.tech/sources/junior-grossi.md>)

Topics: [Eloquent ORM](<https://devfeed.tech/topics/eloquent.md>), [Laravel](<https://devfeed.tech/topics/laravel.md>), [Object-relational mapping](<https://devfeed.tech/topics/orm.md>), [PHP](<https://devfeed.tech/topics/php.md>), [Framework](<https://devfeed.tech/topics/framework.md>)

Tags: [eager-loading](<https://devfeed.tech/tags/eager-loading.md>), [eloquent](<https://devfeed.tech/tags/eloquent.md>), [framework](<https://devfeed.tech/tags/framework.md>), [laravel](<https://devfeed.tech/tags/laravel.md>), [orm](<https://devfeed.tech/tags/orm.md>), [php](<https://devfeed.tech/tags/php.md>), [query](<https://devfeed.tech/tags/query.md>)

### AI overview

A Laravel tutorial explains how to reuse the same anonymous function for filtering posts by related comments and eager loading only the matching comments through Eloquent.

### Source excerpt

Laravel is a PHP framework that uses Eloquent, a powerful and amazing ORM that allows you to do complex SQL queries in a very easy way. But sometimes you need more, and here I'm gonna give you an interesting tip that can bring you a lot of flexibility. When dealing with simple database queries in ... Continue reading Querying and Eager Loading complex relations in Laravel

## QueryFilter: A Model Filtering Concept

DevFeed: [QueryFilter: A Model Filtering Concept](<https://devfeed.tech/articles/queryfilter-a-model-filtering-concept-39018.md>)

Original publisher: [Read original article](<https://blog.jgrossi.com/2018/queryfilter-a-model-filtering-concept/>)

Author: Junior Grossi

Published: 2018-04-23T13:50:39Z

Content type: tutorial

Language: en

Sources: [Junior Grossi](<https://devfeed.tech/sources/junior-grossi.md>)

Topics: [Laravel](<https://devfeed.tech/topics/laravel.md>), [Eloquent ORM](<https://devfeed.tech/topics/eloquent.md>), [PHP](<https://devfeed.tech/topics/php.md>), [WordPress](<https://devfeed.tech/topics/wordpress.md>), [Database](<https://devfeed.tech/topics/database.md>), [JSON](<https://devfeed.tech/topics/json.md>), [Open Source](<https://devfeed.tech/topics/open-source.md>)

Tags: [blog](<https://devfeed.tech/tags/blog.md>), [blog-post](<https://devfeed.tech/tags/blog-post.md>), [clean-code](<https://devfeed.tech/tags/clean-code.md>), [database](<https://devfeed.tech/tags/database.md>), [eloquent](<https://devfeed.tech/tags/eloquent.md>), [json](<https://devfeed.tech/tags/json.md>), [laravel](<https://devfeed.tech/tags/laravel.md>), [open-source](<https://devfeed.tech/tags/open-source.md>), [orm](<https://devfeed.tech/tags/orm.md>), [php](<https://devfeed.tech/tags/php.md>), [query](<https://devfeed.tech/tags/query.md>), [talks](<https://devfeed.tech/tags/talks.md>)

### AI overview

This tutorial presents QueryFilter, a model-filtering concept for Laravel applications using Eloquent ORM. It demonstrates filtering models from URL query parameters, with an example app that returns filtered posts as JSON and uses Corcel to retrieve posts from a WordPress database.

### Source excerpt

Having a clean code with single responsibility is important, and doing that for model filtering can be easy and very powerful. Believe me. This blog post is related to a talk I gave on April, 2018 on Darkmira Tour PHP 2018, in Brasília/DF, Brazil, with the same title. The slides are on SpeakerDeck. Filtering models ... Continue reading QueryFilter: A Model Filtering Concept