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:
Afiq Hamzah
2026-01-20 11:36:41 +08:00
parent 0ac42331d4
commit 8fe42c1d9f
9 changed files with 17 additions and 16 deletions
+2 -2
View File
@@ -203,7 +203,7 @@ class MarhunController extends Controller
$marhun = Marhun::on($cawangan['mysql'])
->select('marhun.norujukan','gadai.nokp','customer.nama','marhun.marhun','marhun.nota','marhun.berat','marhun.karat','marhun.harga','marhun.n_marhun','marhun.t_gadai','marhun.tag_permata', 'marhun.berat_batu_permata')
->rightJoin('gadai', 'gadai.norujukan', '=', 'marhun.norujukan')
->rightJoin('master_krk.customer as customer', 'customer.kpbaru','=','gadai.nokp')
->rightJoin(config('tennant_database.master_db') . '.customer as customer', 'customer.kpbaru','=','gadai.nokp')
->where('marhun.t_gadai','=',$tarikh)
->orderBy('marhun.t_gadai')
->get();
@@ -221,7 +221,7 @@ class MarhunController extends Controller
$marhun = Marhun::on($cawangan['mysql'])
->select('marhun.norujukan','gadai.sttebus','gadai.pinjaman','gadai.nokp','customer.nama','marhun.marhun','marhun.nota','marhun.berat','marhun.karat','marhun.harga','marhun.n_marhun','marhun.t_gadai')
->rightJoin('gadai', 'gadai.norujukan', '=', 'marhun.norujukan')
->rightJoin('master_krk.customer as customer', 'customer.kpbaru','=','gadai.nokp')
->rightJoin(config('tennant_database.master_db') . '.customer as customer', 'customer.kpbaru','=','gadai.nokp')
->where('marhun.t_gadai','<=',$tarikh)
->whereYear('marhun.t_gadai','=',$current->year)
->where('gadai.sttebus','=','')