Skip to content

Instantly share code, notes, and snippets.

@edwinheij
edwinheij / gist:508fbb749b91612f8f0f
Last active February 17, 2017 19:45
Eloquent query logging
<?php
// edit app/config/local/database.php -> 'log' => true
// @ http://stackoverflow.com/questions/19131731/laravel-4-logging-sql-queries
if (Config::get('database.log', false)) {
Event::listen('illuminate.query', function($query, $bindings, $time, $name) {
$data = compact('bindings', 'time', 'name');
// Format binding data for sql insertion
foreach ($bindings as $i => $binding) {