Changeset View
Changeset View
Standalone View
Standalone View
src/app/Providers/AppServiceProvider.php
<?php | <?php | ||||
namespace App\Providers; | namespace App\Providers; | ||||
use Illuminate\Database\Query\Builder; | use Illuminate\Database\Query\Builder; | ||||
use Illuminate\Support\Facades\Blade; | use Illuminate\Support\Facades\Blade; | ||||
use Illuminate\Support\Facades\DB; | use Illuminate\Support\Facades\DB; | ||||
use Illuminate\Support\Facades\Schema; | use Illuminate\Support\Facades\Schema; | ||||
use Illuminate\Support\ServiceProvider; | use Illuminate\Support\ServiceProvider; | ||||
use Laravel\Passport\Passport; | |||||
class AppServiceProvider extends ServiceProvider | class AppServiceProvider extends ServiceProvider | ||||
{ | { | ||||
/** | /** | ||||
* Register any application services. | * Register any application services. | ||||
* | * | ||||
* @return void | * @return void | ||||
*/ | */ | ||||
public function register() | public function register() | ||||
{ | { | ||||
// | Passport::ignoreMigrations(); | ||||
} | |||||
/** | |||||
* Serialize a bindings array to a string. | |||||
* | |||||
* @return string | |||||
*/ | |||||
private static function serializeSQLBindings(array $array): string | |||||
{ | |||||
$serialized = array_map(function ($entry) { | |||||
if ($entry instanceof \DateTime) { | |||||
return $entry->format('Y-m-d h:i:s'); | |||||
} | |||||
return $entry; | |||||
}, $array); | |||||
return implode(', ', $serialized); | |||||
machniak: I don't the indentation above. And I would add a new line before return. | |||||
} | } | ||||
/** | /** | ||||
* Bootstrap any application services. | * Bootstrap any application services. | ||||
* | * | ||||
* @return void | * @return void | ||||
*/ | */ | ||||
public function boot() | public function boot() | ||||
Show All 24 Lines | public function boot() | ||||
// Log SQL queries in debug mode | // Log SQL queries in debug mode | ||||
if (\config('app.debug')) { | if (\config('app.debug')) { | ||||
DB::listen(function ($query) { | DB::listen(function ($query) { | ||||
\Log::debug( | \Log::debug( | ||||
sprintf( | sprintf( | ||||
'[SQL] %s [%s]: %.4f sec.', | '[SQL] %s [%s]: %.4f sec.', | ||||
$query->sql, | $query->sql, | ||||
implode(', ', $query->bindings), | self::serializeSQLBindings($query->bindings), | ||||
$query->time / 1000 | $query->time / 1000 | ||||
) | ) | ||||
); | ); | ||||
}); | }); | ||||
} | } | ||||
// Register some template helpers | // Register some template helpers | ||||
Blade::directive( | Blade::directive( | ||||
▲ Show 20 Lines • Show All 79 Lines • Show Last 20 Lines |
I don't the indentation above. And I would add a new line before return.