diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0faec17..256da35 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,9 @@ Types of changes: `Added`, `Changed`, `Deprecate`, `Removed`, `Fixed`, `Secruity
## [Unreleased]
+### Added
+- Added developer feature to show the executed SQL queries
+
## v2.6.1 - 03.10.2024 - Bugfix in 'Revenue and Profits' view
### Fixed
diff --git a/app/Http/Controllers/DeveloperToolsController.php b/app/Http/Controllers/DeveloperToolsController.php
index 87b3f8a..66ebe87 100644
--- a/app/Http/Controllers/DeveloperToolsController.php
+++ b/app/Http/Controllers/DeveloperToolsController.php
@@ -21,6 +21,7 @@ public function execute(): void
if (Http::requestMethod() === 'POST') {
DeveloperTools::setShowErrorMessages(Http::param('showErrorMessages') === '1');
+ DeveloperTools::setShowSqlQueries(Http::param('showSqlQueries') === '1');
Http::redirect('/');
}
diff --git a/framework/Database/Database.php b/framework/Database/Database.php
index 3a12dad..c6d3dbe 100644
--- a/framework/Database/Database.php
+++ b/framework/Database/Database.php
@@ -2,6 +2,7 @@
namespace Framework\Database;
+use Framework\Authentication\Session;
use Framework\Config\Config;
use Framework\Database\Interface\BlueprintInterface;
use Framework\Database\Interface\DatabaseInterface;
@@ -46,6 +47,9 @@ public static function executeBlueprint(BlueprintInterface $blueprint): ResultIn
public static function unprepared(string $query): ResultInterface|false
{
self::getDb();
+ if (Session::getValue('showSqlQueries') === 'true') {
+ echo $query . '
';
+ }
return self::$db->unprepared($query);
}
@@ -57,6 +61,9 @@ public static function unprepared(string $query): ResultInterface|false
public static function prepared(string $query, string $colTypes, ...$values): ResultInterface|false
{
self::getDb();
+ if (Session::getValue('showSqlQueries') === 'true') {
+ echo $query . '
';
+ }
return self::$db->prepared($query, $colTypes, ...$values);
}
diff --git a/framework/Facades/DeveloperTools.php b/framework/Facades/DeveloperTools.php
index cb34876..ecefc6b 100644
--- a/framework/Facades/DeveloperTools.php
+++ b/framework/Facades/DeveloperTools.php
@@ -28,4 +28,26 @@ public static function setShowErrorMessages(bool $value): void
Session::setValue('showErrorMessages', null);
}
}
+
+ public static function showSqlQueries(): bool
+ {
+ if (!Auth::hasRole('Developer')) {
+ return false;
+ }
+
+ return Session::getValue('showSqlQueries') === 'true';
+ }
+
+ public static function setShowSqlQueries(bool $value): void
+ {
+ if (!Auth::hasRole('Developer')) {
+ return;
+ }
+
+ if ($value) {
+ Session::setValue('showSqlQueries', 'true');
+ } else {
+ Session::setValue('showSqlQueries', null);
+ }
+ }
}
\ No newline at end of file
diff --git a/resources/Lang/de.php b/resources/Lang/de.php
index 6aa7460..b0da3cf 100644
--- a/resources/Lang/de.php
+++ b/resources/Lang/de.php
@@ -126,6 +126,7 @@
'ShowAllUsers' => 'Alle Benutzer anzeigen',
'ShowErrorMessages' => 'Fehlermeldungen anzeigen',
'ShowPayouts' => 'Auszahlungen anzeigen',
+ 'ShowSqlQueries' => 'SQL-Abfragen anzeigen',
'ShowVolumeDistribution' => 'Mengenverteilung anzeigen',
'Street' => 'Straße',
'Subdistrict' => 'Gemarkung',
diff --git a/resources/Lang/en.php b/resources/Lang/en.php
index 6d3ce8d..eee4b10 100644
--- a/resources/Lang/en.php
+++ b/resources/Lang/en.php
@@ -127,6 +127,7 @@
'ShowDeliveryNotes' => 'Show all delivery notes',
'ShowErrorMessages' => 'Show error messages',
'ShowPayouts' => 'Show payouts',
+ 'ShowSqlQueries' => 'Show SQL queries',
'ShowVolumeDistribution' => 'Show volume distribution',
'Street' => 'Street',
'Subdistrict' => 'Subdistrict',
diff --git a/resources/Views/settings/devTools.php b/resources/Views/settings/devTools.php
index 85d2837..2114df3 100644
--- a/resources/Views/settings/devTools.php
+++ b/resources/Views/settings/devTools.php
@@ -13,6 +13,15 @@
= __('ShowErrorMessages') ?>
+
+