My team and I are working on a rather big project. There\'s queries going on everywhere - in controllers, in view composers in views (lazy loading) and probably in some othe
Put this code right above the code where your query is executed
\DB::listen(function($sql) {
die(\Illuminate\Support\Str::replaceArray('?', $sql->bindings, $sql->sql));
});
Just modified for executable query:
\DB::listen(function ($query) {
// Enclose in single quotes for string params.
$bindings = collect($query->bindings)->map(function ($param) {
if(is_numeric($param)) {
return $param;
} else {
return "'$param'";
}
});
\Log::info(\Illuminate\Support\Str::replaceArray('?', $bindings->toArray(), $query->sql));
});