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

# php-eloquent-query-in-loop

> An Eloquent key lookup runs for each PHP foreach item.

## What it flags

The standalone `loadwise perf polyglot` command detects a static Eloquent model lookup inside `foreach` where the lookup takes the current item as its key. The model must visibly extend the Eloquent base class, including through an aliased import.

## How to review or fix

Consider a batched query for independent keys after checking ordering, missing results and authorization or visibility filters.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.