Skip to content

Commit 974fd16

Browse files
committed
Merge pull request barryvdh#433 from kwoodfriend/patch-1
Fix for Laravel 5.2 event changes
2 parents 25ce905 + a717f57 commit 974fd16

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/LaravelDebugbar.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,20 @@ function ($level, $message, $context) use ($logger) {
288288

289289
try {
290290
$db->listen(
291-
function ($query, $bindings, $time, $connectionName) use ($db, $queryCollector) {
292-
$connection = $db->connection($connectionName);
291+
function ($query, $bindings = null, $time = null, $connectionName = null) use ($db, $queryCollector) {
292+
// Laravel 5.2 changed the way some core events worked. We must account for
293+
// the first argument being an "event object", where arguments are passed
294+
// via object properties, instead of individual arguments.
295+
if (version_compare($this->version, '5.2.0', '>=')) {
296+
$bindings = $query->bindings;
297+
$time = $query->time;
298+
$connection = $query->connection;
299+
300+
$query = $query->sql;
301+
} else {
302+
$connection = $db->connection($connectionName);
303+
}
304+
293305
$queryCollector->addQuery((string) $query, $bindings, $time, $connection);
294306
}
295307
);

0 commit comments

Comments
 (0)