Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Helper function for viewing queries ran in Laravel 4
<?php
if (!function_exists('sql')) {
function sql($detailed = false) {
if ($detailed) {
Event::listen("illuminate.query", function($query, $bindings, $time, $name) {
$queries = DB::getQueryLog();
echo '<pre>';
foreach(end($queries) as $item) {
var_dump($item);
}
echo '</pre>';
});
} else {
Event::listen("illuminate.query", function($sql) {
echo '<pre>';
print_r($sql);
echo '</pre>';
});
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment