Skip to content

Instantly share code, notes, and snippets.

@yoelpc4
Created September 27, 2020 20:52
Show Gist options
  • Save yoelpc4/74ec559ed4209198ff7cb27e7e74ffca to your computer and use it in GitHub Desktop.
Save yoelpc4/74ec559ed4209198ff7cb27e7e74ffca to your computer and use it in GitHub Desktop.
Laravel SQL Debug
\DB::listen(function (\Illuminate\Database\Events\QueryExecuted $query) {
$sql = $query->sql;
$bindings = implode(', ', $query->bindings);
$time = $query->time;
\Log::info("\nSQL: {$sql}\nBindings: {$bindings}\nTime: {$time}\n\n");
});
@yoelpc4
Copy link
Author

yoelpc4 commented Sep 27, 2020

Put the snippet above on your AppServiceProvider file at boot method

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment