Skip to content

Instantly share code, notes, and snippets.

@ansezz
Created April 21, 2022 13:07
Show Gist options
  • Save ansezz/e7cf2d96595f667db04a308f8a00ee8a to your computer and use it in GitHub Desktop.
Save ansezz/e7cf2d96595f667db04a308f8a00ee8a to your computer and use it in GitHub Desktop.
<?php
namespace App\Providers;
use Dingo\Api\Auth\Provider\JWT;
use Dingo\Api\Http\RateLimit\Throttle\Authenticated;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
DB::listen(function ($query) {
$sql = $query->sql;
$binds = $query->bindings;
$result = "";
$sql_chunks = explode('?', $sql);
foreach ($sql_chunks as $key => $sql_chunk) {
if (isset($binds[$key])) {
$result .= $sql_chunk . '"' . $binds[$key] . '"';
}
}
$result .= $sql_chunks[count($sql_chunks) - 1];
Log::info($result);
Log::info('Time : ' . $query->time);
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment