# 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