| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 | 
							- <?php
 
- namespace App\Providers;
 
- use App\Models\User;
 
- use Illuminate\Support\ServiceProvider;
 
- use Prettus\Repository\Providers\RepositoryServiceProvider;
 
- class AppServiceProvider extends ServiceProvider
 
- {
 
-     /**
 
-      * Register any application services.
 
-      *
 
-      * @return void
 
-      */
 
-     public function register()
 
-     {
 
-         $this->app->register(RepositoryServiceProvider::class);
 
-         $this->app->singleton('getUserInstance', function (){
 
-             return new User();
 
-         });
 
-     }
 
-     /**
 
-      * Bootstrap any application services.
 
-      *
 
-      * @return void
 
-      */
 
-     public function boot()
 
-     {
 
-         \Schema::defaultStringLength(191);
 
-         // 打印所有sql
 
-         if(config('app.db_log')) {
 
-             \DB::listen(function($query) {
 
-                 // 先替换sql中的 % 避免 vsprintf 当成参数解析报错  Too few arguments
 
-                 $tmp = str_replace('%', '(no-vsprintf)', $query->sql);
 
-                 // \Log::info($tmp);
 
-                 $tmp = str_replace('?', '"'.'%s'.'"', $tmp);
 
-                 // \Log::info($tmp);
 
-                 $tmp = vsprintf($tmp, $query->bindings);
 
-                 $tmp = str_replace("\\","",$tmp);
 
-                 // 还原 %
 
-                 $tmp = str_replace('(no-vsprintf)', '%', $tmp);
 
-                 \Log::info($tmp);
 
-                 //Log::info($tmp."\n\n\t");
 
-            });
 
-        }
 
-     }
 
- }
 
 
  |