Refactor tenant database configuration to use dynamic config values
- Replace hardcoded database names (online_arrahn, master_krk, kaunterpkb) with configurable values across the codebase - Rename tennant_master.php to tennant_database.php for clearer naming - Update config keys: 'database' → 'master_db', add 'kaunter_db' - Update env variables: TENNANT_MASTER_DB and TENNANT_KAUNTER_DB - Modify Helper.php to use dynamic database references in getOnlineArrahnConnection(), getActiveCawanganDbConnection(), and getInactiveCawanganDbConnection() methods - Update database JOIN queries in CustomerController and MarhunController to use config values instead of hardcoded database names - Simplify migration logic by removing redundant hardcoded database checks - Update debug messages in CawanganDebugConnections to show actual configured database name - Update bootstrap/app.php to load tennant_database config This change improves multi-environment flexibility and eliminates environment-specific hardcoded values, making the application more configurable for different deployment scenarios (KRK, KGMK, etc).
This commit is contained in:
@@ -42,7 +42,7 @@ class AddColumnsToKomuditiTransaksi extends Migration
|
||||
{
|
||||
$online_arrahn_connection_array = array_filter(config('database.connections'), function($connection) {
|
||||
|
||||
if($connection['database'] === 'online_arrahn' || $connection['database'] === 'master_krk' || $connection['database'] === config('tennant_master.database')){
|
||||
if($connection['database'] === config('tennant_database.master_db')){
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ class AddColumnsToKomuditiTransaksi extends Migration
|
||||
|
||||
|
||||
if(empty($online_arrahn_connection_array)){
|
||||
throw new Exception("online_arrahn or master_krk doesn't exist in config.database.connections array");
|
||||
throw new Exception("Tennant master database (" . config('tennant_database.master_db') . ") doesn't exist in config.database.connections array");
|
||||
}
|
||||
|
||||
return array_keys($online_arrahn_connection_array)[0];
|
||||
|
||||
Reference in New Issue
Block a user