diff --git a/config/config.php b/config/config.php index cd4e50d..75dc268 100644 --- a/config/config.php +++ b/config/config.php @@ -29,6 +29,10 @@ * Displays an alert on the website * \BeyondCode\QueryDetector\Outputs\Alert::class * + * Debugbar: (make sure you have the barryvdh/laravel-debugbar package installed) + * Writes the N+1 queries into a custom messages collector of Debugbar + * \BeyondCode\QueryDetector\Outputs\Debugbar::class + * * Log: * Writes the N+1 queries into the Laravel.log file * \BeyondCode\QueryDetector\Outputs\Log::class diff --git a/src/Outputs/Debugbar.php b/src/Outputs/Debugbar.php new file mode 100644 index 0000000..fa297b7 --- /dev/null +++ b/src/Outputs/Debugbar.php @@ -0,0 +1,27 @@ +addMessage(sprintf('Model: %s => Relation: %s - You should add with(%s) to eager-load this relation.', + $detectedQuery['model'], + $detectedQuery['relation'], + $detectedQuery['relation'] + )); + } + + LaravelDebugbar::addCollector($collector); + } +}