From 0a9dcfaba702828b821ed574bee266506fb67eec Mon Sep 17 00:00:00 2001 From: noogen Date: Wed, 8 Nov 2023 11:18:15 -0600 Subject: [PATCH] throw exception on invalid tenant and table name --- composer.json | 10 +++++----- src/Traits/TableModelTrait.php | 18 ++++++++++++++---- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/composer.json b/composer.json index ca74763..64b797b 100644 --- a/composer.json +++ b/composer.json @@ -21,13 +21,13 @@ "laravel/framework": ">=8.0", "league/csv": "^9.0", "maatwebsite/excel": "^3.0", - "phpoffice/phpspreadsheet": "^1.23.0", - "yajra/laravel-datatables-oracle": "^9.0" + "phpoffice/phpspreadsheet": "^1.29.0", + "yajra/laravel-datatables-oracle": "^10.0" }, "require-dev": { - "fakerphp/faker": "^1.19", - "friendsofphp/php-cs-fixer": "^3.8.0", - "mockery/mockery": "^1.5", + "fakerphp/faker": "^1.23", + "friendsofphp/php-cs-fixer": "^3.38", + "mockery/mockery": "^1.6", "orchestra/testbench": "^7.4.0", "phpunit/phpunit": "^9.5" }, diff --git a/src/Traits/TableModelTrait.php b/src/Traits/TableModelTrait.php index 770c8be..9996f39 100644 --- a/src/Traits/TableModelTrait.php +++ b/src/Traits/TableModelTrait.php @@ -40,14 +40,14 @@ public function createTableIfNotExists( ) { $tableNew = null; - // invalid tenant, exit - throw exception? + // invalid tenant if (isset($tenant) && ! empty($tenant) && strlen($tenant) < 3) { - return $tableNew; + throw new LarattException(__('exceptions.tenant.invalidname')); } - // invalid table name, exit - throw exception? + // invalid table name if (isset($tableName) && ! empty($tableName) && strlen($tableName) < 3) { - return $tableNew; + throw new LarattException(__('exceptions.tenant.invalidtable')); } $tableNew = $this->setTableName($tenant, $tableName); @@ -78,6 +78,16 @@ public function dropTableIfExists( $tenant, $tableName ) { + // invalid tenant + if (isset($tenant) && ! empty($tenant) && strlen($tenant) < 3) { + throw new LarattException(__('exceptions.tenant.invalidname')); + } + + // invalid table name + if (isset($tableName) && ! empty($tableName) && strlen($tableName) < 3) { + throw new LarattException(__('exceptions.tenant.invalidtable')); + } + $tableNew = $this->setTableName($tenant, $tableName); Schema::dropIfExists($tableNew);