AppServiceProvider.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | RXThinkCMF框架 [ RXThinkCMF ]
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2017~2021 南京RXThinkCMF研发中心
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: http://www.rxthink.cn
  8. // +----------------------------------------------------------------------
  9. // | Author: 牧羊人 <1175401194@qq.com>
  10. // +----------------------------------------------------------------------
  11. namespace App\Providers;
  12. use Illuminate\Support\ServiceProvider;
  13. class AppServiceProvider extends ServiceProvider
  14. {
  15. /**
  16. * Register any application services.
  17. *
  18. * @return void
  19. */
  20. public function register()
  21. {
  22. //
  23. \DB::listen(function ($query) {
  24. $bindings = $query->bindings;
  25. $sql = $query->sql;
  26. foreach ($bindings as $replace) {
  27. $value = is_numeric($replace) ? $replace : "'" . $replace . "'";
  28. $sql = preg_replace('/\?/', $value, $sql, 1);
  29. }
  30. // $time = $query->time;
  31. // if ($time > 10) { //when time > 10 print
  32. // \Log::debug(var_export(compact(['sql', 'bindings', 'time']), true));
  33. // }
  34. // \Log::debug(var_export(compact(['sql', 'bindings', 'time']), true));
  35. // print_r($sql);
  36. // echo $sql;
  37. });
  38. }
  39. /**
  40. * Bootstrap any application services.
  41. *
  42. * @return void
  43. */
  44. public function boot()
  45. {
  46. //
  47. }
  48. }