Add withoutDetection() method for suppressing N+1 detection
## Motivation
The existing except config requires whitelisting by model + relation pair, which is too coarse-grained. In practice, developers often need to suppress detection for a specific code block (e.g. admin pages with small datasets, legacy endpoints, or background jobs) rather than globally whitelisting a relation.
## What I did
- Add QueryDetector::withoutDetection(callable $callback) method that temporarily disables N+1 detection for the duration of the closure
- Uses a simple $disabled flag — no reflection or backtrace scanning overhead
- The closure's return value is passed through
- Detection resumes automatically after the closure, even if it throws an exception
## Usage
```
app(QueryDetector::class)->withoutDetection(function () {
// N+1 queries here will not be reported
foreach (Author::all() as $author) {
$author->posts;
}
});
```
合并状态:未合并 1 条评论