diff --git a/src/SqlCommenterServiceProvider.php b/src/SqlCommenterServiceProvider.php index 8cbf616..8ced129 100644 --- a/src/SqlCommenterServiceProvider.php +++ b/src/SqlCommenterServiceProvider.php @@ -37,7 +37,12 @@ public function packageBooted(): void $connections = [config('database.default')]; } - collect($connections)->each(fn (string $conn) => DB::connection($conn)->beforeExecuting(function ( + collect($connections)->each(fn (string $conn) => $this->initiateForConnection($conn)); + } + + public function initiateForConnection(string $conn): void + { + DB::connection($conn)->beforeExecuting(function ( string &$query, array &$bindings, Connection $connection, @@ -47,7 +52,7 @@ public function packageBooted(): void $commenters = $this->instanciateCommenters(config('sql-commenter.commenters')); $query = $sqlCommenter->commentQuery($query, $connection, $commenters); - })); + }); } /**