@@ -28,6 +28,7 @@ class QueryCollector extends PDOCollector
2828 protected $ showHints = false ;
2929 protected $ showCopyButton = false ;
3030 protected $ reflection = [];
31+ protected $ excludePaths = [];
3132 protected $ backtraceExcludePaths = [
3233 '/vendor/laravel/framework/src/Illuminate/Support ' ,
3334 '/vendor/laravel/framework/src/Illuminate/Database ' ,
@@ -99,6 +100,11 @@ public function setFindSource($value, array $middleware)
99100 $ this ->middleware = $ middleware ;
100101 }
101102
103+ public function mergeExcludePaths (array $ excludePaths )
104+ {
105+ $ this ->excludePaths = array_merge ($ this ->excludePaths , $ excludePaths );
106+ }
107+
102108 /**
103109 * Set additional paths to exclude from the backtrace
104110 *
@@ -491,6 +497,11 @@ public function collect()
491497 default => false ,
492498 };
493499
500+ $ source = $ this ->getDataFormatter ()->formatSource ($ source );
501+ if (Str::startsWith ($ source , $ this ->excludePaths )) {
502+ continue ;
503+ }
504+
494505 $ statements [] = [
495506 'sql ' => $ this ->getSqlQueryToDisplay ($ query ),
496507 'type ' => $ query ['type ' ],
@@ -505,7 +516,7 @@ public function collect()
505516 'memory ' => $ query ['memory ' ],
506517 'memory_str ' => $ query ['memory ' ] ? $ this ->getDataFormatter ()->formatBytes ($ query ['memory ' ]) : null ,
507518 'filename ' => $ this ->getDataFormatter ()->formatSource ($ source , true ),
508- 'source ' => $ this -> getDataFormatter ()-> formatSource ( $ source) ,
519+ 'source ' => $ source ,
509520 'xdebug_link ' => is_object ($ source ) ? $ this ->getXdebugLink ($ source ->file ?: '' , $ source ->line ) : null ,
510521 'connection ' => $ connectionName ,
511522 'explain ' => $ this ->explainQuery && $ canExplainQuery ? [
@@ -568,6 +579,8 @@ public function collect()
568579
569580 $ data = [
570581 'nb_statements ' => $ this ->queryCount ,
582+ 'nb_visible_statements ' => count ($ statements ),
583+ 'nb_excluded_statements ' => $ this ->queryCount - count ($ statements ),
571584 'nb_failed_statements ' => 0 ,
572585 'accumulated_duration ' => $ totalTime ,
573586 'accumulated_duration_str ' => $ this ->formatDuration ($ totalTime ),
@@ -599,7 +612,7 @@ public function getWidgets()
599612 "default " => "[] "
600613 ],
601614 "queries:badge " => [
602- "map " => "queries.nb_statements " ,
615+ "map " => "queries.nb_visible_statements " ,
603616 "default " => 0
604617 ]
605618 ];
0 commit comments