Created
August 31, 2022 08:30
-
-
Save acip/f656ee3e53000004df4fc04b8eaffc6b to your computer and use it in GitHub Desktop.
Display executed queries in Laravel blade (counting duplicates)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@php | |
// requires \DB::enableQueryLog(); to be executed for the query log is available | |
$queries = array_count_values(array_column(\DB::getQueryLog(), 'query')); | |
arsort($queries); | |
echo "\n"; | |
foreach($queries as $query => $count) { | |
echo sprintf("%s: %s\n", $count > 1 ? "<span style='color:red'>{$count}</span>" : $count, $query); | |
} | |
@endphp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment