Catch N+1 queries before production does
Throw an exception whenever a relationship is lazy loaded, but only outside production so a missed eager load never takes the site down.
use Illuminate\Database\Eloquent\Model;
// app/Providers/AppServiceProvider.php
public function boot(): void
{
Model::preventLazyLoading(! $this->app->isProduction());
}