From 0bab27dab5fbe4bb0d20d0b0fa1a3b1c7b6eaa93 Mon Sep 17 00:00:00 2001 From: Aleksandr Evsigneev Date: Thu, 31 Oct 2019 18:41:34 +0300 Subject: [PATCH] Setting laravel event dispatcher in the connection for logging queries --- src/Integrations/Laravel/ClickhouseServiceProvider.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Integrations/Laravel/ClickhouseServiceProvider.php b/src/Integrations/Laravel/ClickhouseServiceProvider.php index dc1b714..6723777 100644 --- a/src/Integrations/Laravel/ClickhouseServiceProvider.php +++ b/src/Integrations/Laravel/ClickhouseServiceProvider.php @@ -16,7 +16,13 @@ public function boot() $db->extend('clickhouse', function ($config, $name) { $config['name'] = $name; - return new Connection($config); + $connection = new Connection($config); + + if ($this->app->bound('events')) { + $connection->setEventDispatcher($this->app['events']); + } + + return $connection; }); } }