I’ve recently had to do some model relationship debugging in Laravel 4 and needed to figure out how to see the actual queries that were being run. Here’s a quick way to view the last query that your application ran.

$queries = DB::getQueryLog();
$lastQuery = end($queries);
print_r($lastQuery);

UPDATE FOR LARAVEL 5

In some cases, before the above code will work you need to put the following code in bootstrap/app.php:

$app['events']->listen('artisan.start', function(){
    \DB::enableQueryLog();
});

Also remember that if you’re using multiple DB connections, you need to use DB::connection->('connection_name')->getQueryLog(); instead.