// Debug SQL query
// app/Providers/AppServiceProvider.php
public function boot()
{
//...
$this->debugQueries();
}
protected function debugQueries()
{
if (env('APP_DEBUG_QUERIES')) {
DB::listen(function ($query) {
error_log(
"Query [$query->time ms]: $query->sql
"
. "Params: " . print_r($query->bindings, true)
);
});
}
}