Created
April 21, 2022 13:07
-
-
Save ansezz/e7cf2d96595f667db04a308f8a00ee8a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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