Skip to content

Commit ad3df19

Browse files
authored
Merge pull request #26 from erikverbeek/expandedConsoleInformation
Expanded the console log warning with the same details as the laravel.log
2 parents 0ae9a6b + aeb4a48 commit ad3df19

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/Outputs/Alert.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ protected function getOutputContent(Collection $detectedQueries)
4141
$output = '<script type="text/javascript">';
4242
$output .= "alert('Found the following N+1 queries in this request:\\n\\n";
4343
foreach ($detectedQueries as $detectedQuery) {
44-
$output .= "Model: ".addslashes($detectedQuery['model']). " => Relation: ".addslashes($detectedQuery['relation']);
44+
$output .= "Model: ".addslashes($detectedQuery['model'])." => Relation: ".addslashes($detectedQuery['relation']);
4545
$output .= " - You should add \"with(\'".addslashes($detectedQuery['relation'])."\')\" to eager-load this relation.";
4646
$output .= "\\n";
4747
}

src/Outputs/Console.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,18 @@ protected function getOutputContent(Collection $detectedQueries)
4141
$output = '<script type="text/javascript">';
4242
$output .= "console.warn('Found the following N+1 queries in this request:\\n\\n";
4343
foreach ($detectedQueries as $detectedQuery) {
44-
$output .= "Model: ".addslashes($detectedQuery['model']). " => Relation: ".addslashes($detectedQuery['relation']);
44+
$output .= "Model: ".addslashes($detectedQuery['model'])." => Relation: ".addslashes($detectedQuery['relation']);
4545
$output .= " - You should add \"with(\'".$detectedQuery['relation']."\')\" to eager-load this relation.";
46+
$output .= "\\n\\n";
47+
$output .= "Model: ".addslashes($detectedQuery['model'])."\\n";
48+
$output .= "Relation: ".$detectedQuery['relation']."\\n";
49+
$output .= "Num-Called: ".$detectedQuery['count']."\\n";
4650
$output .= "\\n";
51+
$output .= 'Call-Stack:\\n';
52+
53+
foreach ($detectedQuery['sources'] as $source) {
54+
$output .= "#$source->index $source->name:$source->line\\n";
55+
}
4756
}
4857
$output .= "')";
4958
$output .= '</script>';

0 commit comments

Comments
 (0)