From eb90d857221bfb67e47cb66dc8d077cb1527ed7a Mon Sep 17 00:00:00 2001 From: jitendra Date: Tue, 24 Nov 2020 17:07:35 +0530 Subject: [PATCH] Excluded module if they dont have models, views and queries --- composer.lock | 271 ++++++++++++------ .../src/DataCollector/ModuleCollectior.php | 74 ++++- .../src/Providers/DebugBarServiceProvider.php | 3 +- 3 files changed, 238 insertions(+), 110 deletions(-) diff --git a/composer.lock b/composer.lock index 4ecabf026..316e7a513 100644 --- a/composer.lock +++ b/composer.lock @@ -8,16 +8,16 @@ "packages": [ { "name": "algolia/algoliasearch-client-php", - "version": "2.7.0", + "version": "2.7.2", "source": { "type": "git", "url": "https://github.com/algolia/algoliasearch-client-php.git", - "reference": "ce8b35a5aa842ad3e0dc05bbd7aaf5ed82481d71" + "reference": "a915109c76d5f4af67f10cd21855ea2d4c9aec9f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/algolia/algoliasearch-client-php/zipball/ce8b35a5aa842ad3e0dc05bbd7aaf5ed82481d71", - "reference": "ce8b35a5aa842ad3e0dc05bbd7aaf5ed82481d71", + "url": "https://api.github.com/repos/algolia/algoliasearch-client-php/zipball/a915109c76d5f4af67f10cd21855ea2d4c9aec9f", + "reference": "a915109c76d5f4af67f10cd21855ea2d4c9aec9f", "shasum": "" }, "require": { @@ -74,20 +74,20 @@ "php", "search" ], - "time": "2020-06-25T08:47:13+00:00" + "time": "2020-11-24T10:16:46+00:00" }, { "name": "astrotomic/laravel-translatable", - "version": "v11.9.0", + "version": "v11.9.1", "source": { "type": "git", "url": "https://github.com/Astrotomic/laravel-translatable.git", - "reference": "85a36a4c909fa1b5c800f50f91b96b433bdbfd2c" + "reference": "d853a3c34be42941dc83c5cddd9e1e98c71abae1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Astrotomic/laravel-translatable/zipball/85a36a4c909fa1b5c800f50f91b96b433bdbfd2c", - "reference": "85a36a4c909fa1b5c800f50f91b96b433bdbfd2c", + "url": "https://api.github.com/repos/Astrotomic/laravel-translatable/zipball/d853a3c34be42941dc83c5cddd9e1e98c71abae1", + "reference": "d853a3c34be42941dc83c5cddd9e1e98c71abae1", "shasum": "" }, "require": { @@ -139,20 +139,20 @@ "laravel", "translation" ], - "time": "2020-09-09T19:37:03+00:00" + "time": "2020-11-19T14:10:38+00:00" }, { "name": "babenkoivan/elastic-adapter", - "version": "v1.7.2", + "version": "v1.9.0", "source": { "type": "git", "url": "https://github.com/babenkoivan/elastic-adapter.git", - "reference": "aec0cf336f0efe605ac055dbdeaab80b5e25a5c5" + "reference": "e9e984e6d171235219d99b29992e3a001d5551b4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/babenkoivan/elastic-adapter/zipball/aec0cf336f0efe605ac055dbdeaab80b5e25a5c5", - "reference": "aec0cf336f0efe605ac055dbdeaab80b5e25a5c5", + "url": "https://api.github.com/repos/babenkoivan/elastic-adapter/zipball/e9e984e6d171235219d99b29992e3a001d5551b4", + "reference": "e9e984e6d171235219d99b29992e3a001d5551b4", "shasum": "" }, "require": { @@ -188,7 +188,7 @@ "elasticsearch", "php" ], - "time": "2020-10-11T15:54:20+00:00" + "time": "2020-11-14T15:09:00+00:00" }, { "name": "babenkoivan/elastic-client", @@ -986,16 +986,16 @@ }, { "name": "egulias/email-validator", - "version": "2.1.23", + "version": "2.1.24", "source": { "type": "git", "url": "https://github.com/egulias/EmailValidator.git", - "reference": "5fa792ad1853ae2bc60528dd3e5cbf4542d3c1df" + "reference": "ca90a3291eee1538cd48ff25163240695bd95448" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/egulias/EmailValidator/zipball/5fa792ad1853ae2bc60528dd3e5cbf4542d3c1df", - "reference": "5fa792ad1853ae2bc60528dd3e5cbf4542d3c1df", + "url": "https://api.github.com/repos/egulias/EmailValidator/zipball/ca90a3291eee1538cd48ff25163240695bd95448", + "reference": "ca90a3291eee1538cd48ff25163240695bd95448", "shasum": "" }, "require": { @@ -1040,20 +1040,20 @@ "validation", "validator" ], - "time": "2020-10-31T20:37:35+00:00" + "time": "2020-11-14T15:56:27+00:00" }, { "name": "elasticsearch/elasticsearch", - "version": "v7.9.1", + "version": "v7.10.0", "source": { "type": "git", "url": "https://github.com/elastic/elasticsearch-php.git", - "reference": "38e821f37491bd91fe06b18b88613128950a11bb" + "reference": "f4a5741f1d1966a4d0a3a3f68666e6d81432c343" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/elastic/elasticsearch-php/zipball/38e821f37491bd91fe06b18b88613128950a11bb", - "reference": "38e821f37491bd91fe06b18b88613128950a11bb", + "url": "https://api.github.com/repos/elastic/elasticsearch-php/zipball/f4a5741f1d1966a4d0a3a3f68666e6d81432c343", + "reference": "f4a5741f1d1966a4d0a3a3f68666e6d81432c343", "shasum": "" }, "require": { @@ -1066,6 +1066,7 @@ "cpliakas/git-wrapper": "~2.0", "doctrine/inflector": "^1.3", "ext-yaml": "*", + "ext-zip": "*", "mockery/mockery": "^1.2", "phpstan/phpstan": "^0.12", "phpunit/phpunit": "^7.5", @@ -1104,7 +1105,7 @@ "elasticsearch", "search" ], - "time": "2020-10-06T13:03:50+00:00" + "time": "2020-11-11T16:31:00+00:00" }, { "name": "ezimuel/guzzlestreams", @@ -1845,16 +1846,16 @@ }, { "name": "konekt/enum-eloquent", - "version": "1.6.0", + "version": "1.6.1", "source": { "type": "git", "url": "https://github.com/artkonekt/enum-eloquent.git", - "reference": "4f6134f83e41da5501c0790584f9bc385f5b64b8" + "reference": "ef916a58df1db96f3d7d3f5c98451f48535d5c6d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/artkonekt/enum-eloquent/zipball/4f6134f83e41da5501c0790584f9bc385f5b64b8", - "reference": "4f6134f83e41da5501c0790584f9bc385f5b64b8", + "url": "https://api.github.com/repos/artkonekt/enum-eloquent/zipball/ef916a58df1db96f3d7d3f5c98451f48535d5c6d", + "reference": "ef916a58df1db96f3d7d3f5c98451f48535d5c6d", "shasum": "" }, "require": { @@ -1864,7 +1865,6 @@ }, "require-dev": { "illuminate/events": "5.*|6.*|7.*|8.*", - "ocramius/package-versions": "^1.2", "phpunit/phpunit": "6.3 - 7.5|~8.0" }, "type": "library", @@ -1909,7 +1909,7 @@ "konekt", "laravel" ], - "time": "2020-09-12T07:02:31+00:00" + "time": "2020-11-04T12:08:02+00:00" }, { "name": "laravel/framework", @@ -3012,16 +3012,16 @@ }, { "name": "myclabs/php-enum", - "version": "1.7.6", + "version": "1.7.7", "source": { "type": "git", "url": "https://github.com/myclabs/php-enum.git", - "reference": "5f36467c7a87e20fbdc51e524fd8f9d1de80187c" + "reference": "d178027d1e679832db9f38248fcc7200647dc2b7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/php-enum/zipball/5f36467c7a87e20fbdc51e524fd8f9d1de80187c", - "reference": "5f36467c7a87e20fbdc51e524fd8f9d1de80187c", + "url": "https://api.github.com/repos/myclabs/php-enum/zipball/d178027d1e679832db9f38248fcc7200647dc2b7", + "reference": "d178027d1e679832db9f38248fcc7200647dc2b7", "shasum": "" }, "require": { @@ -3054,7 +3054,7 @@ "keywords": [ "enum" ], - "time": "2020-02-14T08:15:52+00:00" + "time": "2020-11-14T18:14:52+00:00" }, { "name": "namshi/jose", @@ -3252,16 +3252,16 @@ }, { "name": "opis/closure", - "version": "3.6.0", + "version": "3.6.1", "source": { "type": "git", "url": "https://github.com/opis/closure.git", - "reference": "c547f8262a5fa9ff507bd06cc394067b83a75085" + "reference": "943b5d70cc5ae7483f6aff6ff43d7e34592ca0f5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/opis/closure/zipball/c547f8262a5fa9ff507bd06cc394067b83a75085", - "reference": "c547f8262a5fa9ff507bd06cc394067b83a75085", + "url": "https://api.github.com/repos/opis/closure/zipball/943b5d70cc5ae7483f6aff6ff43d7e34592ca0f5", + "reference": "943b5d70cc5ae7483f6aff6ff43d7e34592ca0f5", "shasum": "" }, "require": { @@ -3309,7 +3309,95 @@ "serialization", "serialize" ], - "time": "2020-10-11T21:42:15+00:00" + "time": "2020-11-07T02:01:34+00:00" + }, + { + "name": "paypal/paypal-checkout-sdk", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/paypal/Checkout-PHP-SDK.git", + "reference": "ed6a55075448308b87a8b59dcb7fedf04a048cb1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/paypal/Checkout-PHP-SDK/zipball/ed6a55075448308b87a8b59dcb7fedf04a048cb1", + "reference": "ed6a55075448308b87a8b59dcb7fedf04a048cb1", + "shasum": "" + }, + "require": { + "paypal/paypalhttp": "1.0.0" + }, + "require-dev": { + "phpunit/phpunit": "^5.7" + }, + "type": "library", + "autoload": { + "psr-4": { + "PayPalCheckoutSdk\\": "lib/PayPalCheckoutSdk", + "Sample\\": "samples/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "https://github.com/paypal/Checkout-PHP-SDK/blob/master/LICENSE" + ], + "authors": [ + { + "name": "PayPal", + "homepage": "https://github.com/paypal/Checkout-PHP-SDK/contributors" + } + ], + "description": "PayPal's PHP SDK for Checkout REST APIs", + "homepage": "http://github.com/paypal/Checkout-PHP-SDK/", + "keywords": [ + "checkout", + "orders", + "payments", + "paypal", + "rest", + "sdk" + ], + "time": "2019-11-07T23:16:44+00:00" + }, + { + "name": "paypal/paypalhttp", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/paypal/paypalhttp_php.git", + "reference": "1ad9b846a046f09d6135cbf2cbaa7701bbc630a3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/paypal/paypalhttp_php/zipball/1ad9b846a046f09d6135cbf2cbaa7701bbc630a3", + "reference": "1ad9b846a046f09d6135cbf2cbaa7701bbc630a3", + "shasum": "" + }, + "require": { + "ext-curl": "*" + }, + "require-dev": { + "phpunit/phpunit": "^5.7", + "wiremock-php/wiremock-php": "1.43.2" + }, + "type": "library", + "autoload": { + "psr-4": { + "PayPalHttp\\": "lib/PayPalHttp" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PayPal", + "homepage": "https://github.com/paypal/paypalhttp_php/contributors" + } + ], + "time": "2019-11-06T21:27:12+00:00" }, { "name": "paypal/paypal-checkout-sdk", @@ -6422,23 +6510,23 @@ }, { "name": "voku/portable-ascii", - "version": "1.5.3", + "version": "1.5.6", "source": { "type": "git", "url": "https://github.com/voku/portable-ascii.git", - "reference": "25bcbf01678930251fd572891447d9e318a6e2b8" + "reference": "80953678b19901e5165c56752d087fc11526017c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/voku/portable-ascii/zipball/25bcbf01678930251fd572891447d9e318a6e2b8", - "reference": "25bcbf01678930251fd572891447d9e318a6e2b8", + "url": "https://api.github.com/repos/voku/portable-ascii/zipball/80953678b19901e5165c56752d087fc11526017c", + "reference": "80953678b19901e5165c56752d087fc11526017c", "shasum": "" }, "require": { "php": ">=7.0.0" }, "require-dev": { - "phpunit/phpunit": "~6.0 || ~7.0" + "phpunit/phpunit": "~6.0 || ~7.0 || ~9.0" }, "suggest": { "ext-intl": "Use Intl for transliterator_transliterate() support" @@ -6466,7 +6554,7 @@ "clean", "php" ], - "time": "2020-07-22T23:32:04+00:00" + "time": "2020-11-12T00:07:28+00:00" } ], "packages-dev": [ @@ -6942,16 +7030,16 @@ }, { "name": "codeception/module-webdriver", - "version": "1.1.3", + "version": "1.1.4", "source": { "type": "git", "url": "https://github.com/Codeception/module-webdriver.git", - "reference": "b7dc227f91730e7abb520439decc9ad0677b8a55" + "reference": "f719edc1eca033e0dc5fd8d99db122070b1fb933" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Codeception/module-webdriver/zipball/b7dc227f91730e7abb520439decc9ad0677b8a55", - "reference": "b7dc227f91730e7abb520439decc9ad0677b8a55", + "url": "https://api.github.com/repos/Codeception/module-webdriver/zipball/f719edc1eca033e0dc5fd8d99db122070b1fb933", + "reference": "f719edc1eca033e0dc5fd8d99db122070b1fb933", "shasum": "" }, "require": { @@ -6990,7 +7078,7 @@ "browser-testing", "codeception" ], - "time": "2020-10-24T15:41:19+00:00" + "time": "2020-11-16T06:50:15+00:00" }, { "name": "codeception/phpunit-wrapper", @@ -7068,36 +7156,31 @@ }, { "name": "doctrine/instantiator", - "version": "1.3.1", + "version": "1.4.0", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "f350df0268e904597e3bd9c4685c53e0e333feea" + "reference": "d56bf6102915de5702778fe20f2de3b2fe570b5b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/f350df0268e904597e3bd9c4685c53e0e333feea", - "reference": "f350df0268e904597e3bd9c4685c53e0e333feea", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/d56bf6102915de5702778fe20f2de3b2fe570b5b", + "reference": "d56bf6102915de5702778fe20f2de3b2fe570b5b", "shasum": "" }, "require": { "php": "^7.1 || ^8.0" }, "require-dev": { - "doctrine/coding-standard": "^6.0", + "doctrine/coding-standard": "^8.0", "ext-pdo": "*", "ext-phar": "*", - "phpbench/phpbench": "^0.13", - "phpstan/phpstan-phpunit": "^0.11", - "phpstan/phpstan-shim": "^0.11", - "phpunit/phpunit": "^7.0" + "phpbench/phpbench": "^0.13 || 1.0.0-alpha2", + "phpstan/phpstan": "^0.12", + "phpstan/phpstan-phpunit": "^0.12", + "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.2.x-dev" - } - }, "autoload": { "psr-4": { "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" @@ -7111,7 +7194,7 @@ { "name": "Marco Pivetta", "email": "ocramius@gmail.com", - "homepage": "http://ocramius.github.com/" + "homepage": "https://ocramius.github.io/" } ], "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", @@ -7120,7 +7203,7 @@ "constructor", "instantiate" ], - "time": "2020-05-29T17:27:14+00:00" + "time": "2020-11-10T18:47:58+00:00" }, { "name": "facade/ignition-contracts", @@ -7410,16 +7493,16 @@ }, { "name": "myclabs/deep-copy", - "version": "1.10.1", + "version": "1.10.2", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "969b211f9a51aa1f6c01d1d2aef56d3bd91598e5" + "reference": "776f831124e9c62e1a2c601ecc52e776d8bb7220" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/969b211f9a51aa1f6c01d1d2aef56d3bd91598e5", - "reference": "969b211f9a51aa1f6c01d1d2aef56d3bd91598e5", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/776f831124e9c62e1a2c601ecc52e776d8bb7220", + "reference": "776f831124e9c62e1a2c601ecc52e776d8bb7220", "shasum": "" }, "require": { @@ -7454,7 +7537,7 @@ "object", "object graph" ], - "time": "2020-06-29T13:22:24+00:00" + "time": "2020-11-13T09:40:50+00:00" }, { "name": "nunomaduro/collision", @@ -7630,23 +7713,23 @@ }, { "name": "php-webdriver/webdriver", - "version": "1.8.3", + "version": "1.9.0", "source": { "type": "git", "url": "https://github.com/php-webdriver/php-webdriver.git", - "reference": "fb0fc4cb01c70a7790a5fcc91d461b88c83174a2" + "reference": "e3633154554605274cc9d59837f55a7427d72003" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-webdriver/php-webdriver/zipball/fb0fc4cb01c70a7790a5fcc91d461b88c83174a2", - "reference": "fb0fc4cb01c70a7790a5fcc91d461b88c83174a2", + "url": "https://api.github.com/repos/php-webdriver/php-webdriver/zipball/e3633154554605274cc9d59837f55a7427d72003", + "reference": "e3633154554605274cc9d59837f55a7427d72003", "shasum": "" }, "require": { "ext-curl": "*", "ext-json": "*", "ext-zip": "*", - "php": "^5.6 || ~7.0", + "php": "^5.6 || ~7.0 || ^8.0", "symfony/polyfill-mbstring": "^1.12", "symfony/process": "^2.8 || ^3.1 || ^4.0 || ^5.0" }, @@ -7656,12 +7739,10 @@ "require-dev": { "friendsofphp/php-cs-fixer": "^2.0", "ondram/ci-detector": "^2.1 || ^3.5", - "php-coveralls/php-coveralls": "^2.0", - "php-mock/php-mock-phpunit": "^1.1", + "php-coveralls/php-coveralls": "^2.4", + "php-mock/php-mock-phpunit": "^1.1 || ^2.0", "php-parallel-lint/php-parallel-lint": "^1.2", - "phpunit/phpunit": "^5.7", - "sebastian/environment": "^1.3.4 || ^2.0 || ^3.0", - "sminnee/phpunit-mock-objects": "^3.4", + "phpunit/phpunit": "^5.7 || ^7 || ^8 || ^9", "squizlabs/php_codesniffer": "^3.5", "symfony/var-dumper": "^3.3 || ^4.0 || ^5.0" }, @@ -7695,7 +7776,7 @@ "selenium", "webdriver" ], - "time": "2020-10-06T19:10:04+00:00" + "time": "2020-11-19T15:21:05+00:00" }, { "name": "phpdocumentor/reflection-common", @@ -8161,39 +8242,39 @@ }, { "name": "phpunit/phpunit", - "version": "8.5.8", + "version": "8.5.9", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "34c18baa6a44f1d1fbf0338907139e9dce95b997" + "reference": "f5c8a5dd5e7e8d68d7562bfb48d47287d33937d6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/34c18baa6a44f1d1fbf0338907139e9dce95b997", - "reference": "34c18baa6a44f1d1fbf0338907139e9dce95b997", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/f5c8a5dd5e7e8d68d7562bfb48d47287d33937d6", + "reference": "f5c8a5dd5e7e8d68d7562bfb48d47287d33937d6", "shasum": "" }, "require": { - "doctrine/instantiator": "^1.2.0", + "doctrine/instantiator": "^1.3.1", "ext-dom": "*", "ext-json": "*", "ext-libxml": "*", "ext-mbstring": "*", "ext-xml": "*", "ext-xmlwriter": "*", - "myclabs/deep-copy": "^1.9.1", + "myclabs/deep-copy": "^1.10.0", "phar-io/manifest": "^1.0.3", "phar-io/version": "^2.0.1", "php": "^7.2", - "phpspec/prophecy": "^1.8.1", - "phpunit/php-code-coverage": "^7.0.7", + "phpspec/prophecy": "^1.10.3", + "phpunit/php-code-coverage": "^7.0.10", "phpunit/php-file-iterator": "^2.0.2", "phpunit/php-text-template": "^1.2.1", "phpunit/php-timer": "^2.1.2", "sebastian/comparator": "^3.0.2", "sebastian/diff": "^3.0.2", - "sebastian/environment": "^4.2.2", - "sebastian/exporter": "^3.1.1", + "sebastian/environment": "^4.2.3", + "sebastian/exporter": "^3.1.2", "sebastian/global-state": "^3.0.0", "sebastian/object-enumerator": "^3.0.3", "sebastian/resource-operations": "^2.0.1", @@ -8240,7 +8321,7 @@ "testing", "xunit" ], - "time": "2020-06-22T07:06:58+00:00" + "time": "2020-11-10T12:51:38+00:00" }, { "name": "sebastian/code-unit-reverse-lookup", diff --git a/packages/Webkul/DebugBar/src/DataCollector/ModuleCollectior.php b/packages/Webkul/DebugBar/src/DataCollector/ModuleCollectior.php index b2f3c4467..9311a50d2 100644 --- a/packages/Webkul/DebugBar/src/DataCollector/ModuleCollectior.php +++ b/packages/Webkul/DebugBar/src/DataCollector/ModuleCollectior.php @@ -38,7 +38,6 @@ class ModuleCollector extends DataCollector implements DataCollectorInterface, R $events->listen('eloquent.*', function ($event, $models) { if (Str::contains($event, 'eloquent.retrieved')) { foreach (array_filter($models) as $model) { - // dd($model, $model->getTable()); $class = get_class($model); $this->models[$class] = ($this->models[$class] ?? 0) + 1; $this->count++; @@ -47,18 +46,15 @@ class ModuleCollector extends DataCollector implements DataCollectorInterface, R }); $events->listen('composing:*', function ($view, $data = []) { - if ($data) { - $view = $data[0]; - } + $view = $data ? $data[0] : $view; $this->views[] = $this->trimViewName($view->getName(), $view->getPath()); }); - app()['db']->listen( function ($query, $bindings = null, $time = null, $connectionName = null) use ($pdoCollector) { $this->queries[] = [ - 'sql' => $query->sql, + 'sql' => $this->addQueryBindings($query), 'duration' => $query->time, "duration_str" => $pdoCollector->formatDuration($query->time), "connection" => $query->connection->getDatabaseName() @@ -67,6 +63,50 @@ class ModuleCollector extends DataCollector implements DataCollectorInterface, R ); } + /** + * @param \Illuminate\Database\Events\QueryExecuted $query + * @return string + */ + public function addQueryBindings($query) + { + $sql = $query->sql; + + $bindings = $this->checkBindings($query->connection->prepareBindings($query->bindings)); + + if (! empty($bindings)) { + foreach ($bindings as $key => $binding) { + $regex = is_numeric($key) + ? "/\?(?=(?:[^'\\\']*'[^'\\\']*')*[^'\\\']*$)/" + : "/:{$key}(?=(?:[^'\\\']*'[^'\\\']*')*[^'\\\']*$)/"; + + if (! is_int($binding) && ! is_float($binding)) { + $binding = $query->connection->getPdo()->quote($binding); + } + + $sql = preg_replace($regex, $binding, $sql, 1); + } + } + + return $sql; + } + + /** + * Check bindings for illegal (non UTF-8) strings, like Binary data. + * + * @param array $bindings + * @return mixed + */ + public function checkBindings($bindings) + { + foreach ($bindings as &$binding) { + if (is_string($binding) && ! mb_check_encoding($binding, 'UTF-8')) { + $binding = '[BINARY DATA]'; + } + } + + return $bindings; + } + /** * @param string $name * @param string $path @@ -89,16 +129,22 @@ class ModuleCollector extends DataCollector implements DataCollectorInterface, R $modules = []; foreach (Concord::getModules() as $moduleId => $module) { - $modules[] = [ - 'name' => $module->getNamespaceRoot(), - 'models' => $this->getModels($module->getNamespaceRoot()), - 'views' => $this->getTemplates($module->getNamespaceRoot()), - 'queries' => $this->getQueries($module->getNamespaceRoot()), - ]; + $models = $this->getModels($module->getNamespaceRoot()); + + $views = $this->getTemplates($module->getNamespaceRoot()); + + $queries = $this->getQueries($module->getNamespaceRoot()); + + if (count($models) || count($views) || count($queries)) { + $modules[] = [ + 'name' => $module->getNamespaceRoot(), + 'models' => $models, + 'views' => $views, + 'queries' => $queries, + ]; + } } - // dd($modules); - $data = [ 'count' => count($modules), 'modules' => $modules, diff --git a/packages/Webkul/DebugBar/src/Providers/DebugBarServiceProvider.php b/packages/Webkul/DebugBar/src/Providers/DebugBarServiceProvider.php index 5dbc8ab88..d43887ae1 100644 --- a/packages/Webkul/DebugBar/src/Providers/DebugBarServiceProvider.php +++ b/packages/Webkul/DebugBar/src/Providers/DebugBarServiceProvider.php @@ -3,6 +3,7 @@ namespace Webkul\DebugBar\Providers; use Illuminate\Support\ServiceProvider; +use Webkul\DebugBar\DataCollector\ModuleCollector; use Debugbar; class DebugBarServiceProvider extends ServiceProvider @@ -18,6 +19,6 @@ class DebugBarServiceProvider extends ServiceProvider */ public function register() { - Debugbar::addCollector(app(\Webkul\DebugBar\DataCollector\ModuleCollector::class)); + Debugbar::addCollector(app(ModuleCollector::class)); } } \ No newline at end of file