Skip to content

Commit

Permalink
FIx for Laravel 5.2 event changes
Browse files Browse the repository at this point in the history
Fixes "Missing argument 2 for Barryvdh\Debugbar\LaravelDebugbar::Barryvdh\Debugbar{closure}() is the specific error." exception
  • Loading branch information
Kevin Friend committed Dec 21, 2015
1 parent 25ce905 commit a717f57
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/LaravelDebugbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,20 @@ function ($level, $message, $context) use ($logger) {

try {
$db->listen(
function ($query, $bindings, $time, $connectionName) use ($db, $queryCollector) {
$connection = $db->connection($connectionName);
function ($query, $bindings = null, $time = null, $connectionName = null) use ($db, $queryCollector) {
// Laravel 5.2 changed the way some core events worked. We must account for
// the first argument being an "event object", where arguments are passed
// via object properties, instead of individual arguments.
if (version_compare($this->version, '5.2.0', '>=')) {
$bindings = $query->bindings;
$time = $query->time;
$connection = $query->connection;

$query = $query->sql;
} else {
$connection = $db->connection($connectionName);
}

$queryCollector->addQuery((string) $query, $bindings, $time, $connection);
}
);
Expand Down

0 comments on commit a717f57

Please sign in to comment.