Skip to content

Commit

Permalink
throw exception on invalid tenant and table name
Browse files Browse the repository at this point in the history
  • Loading branch information
noogen committed Nov 8, 2023
1 parent 903f623 commit 0a9dcfa
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
18 changes: 14 additions & 4 deletions src/Traits/TableModelTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 0a9dcfa

Please sign in to comment.