You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.9 KiB

5 years ago
<?php
namespace App\Providers;
use Illuminate\Auth\Events\Registered;
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
2 years ago
use Illuminate\Support\Facades\DB;
5 years ago
use Illuminate\Support\Facades\Event;
2 years ago
use Illuminate\Support\Facades\Log;
5 years ago
class EventServiceProvider extends ServiceProvider
{
/**
* The event listener mappings for the application.
*
* @var array
*/
protected $listen = [
Registered::class => [
SendEmailVerificationNotification::class,
],
"App\Events\FactorSaved" => ["App\Listeners\FactorSavedListener"],
"App\Events\ManagerSaved" => ["App\Listeners\ManagerSavedListener"],
3 years ago
"App\Events\AdminSaved" => ["App\Listeners\AdminSavedListener"],
5 years ago
"App\Events\ProjectSaved" => ["App\Listeners\ProjectSavedListener"],
"App\Events\ProductSaved" => ["App\Listeners\ProductSavedListener"],
"App\Events\RechargeSucceed" => ["App\Listeners\RechargeSucceedListener"],
"App\Events\OrderAssigned" => ["App\Listeners\OrderAssignedListener"],
];
/**
* Register any events for your application.
*
* @return void
*/
public function boot()
{
parent::boot();
2 years ago
DB::listen(
function ($query) {
$tmp = str_replace('?', '"' . '%s' . '"', $query->sql);
$qBindings = [];
foreach ($query->bindings as $key => $value) {
if (is_numeric($key)) {
$qBindings[] = $value;
} else {
$tmp = str_replace(':' . $key, '"' . $value . '"', $tmp);
}
}
$tmp = vsprintf($tmp, $qBindings);
$tmp = str_replace("\\", "", $tmp);
Log::info(' execution time: ' . $query->time . 'ms; ' . $tmp . "\n\t");
}
);
5 years ago
}
}