Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

26 řádky
698B

  1. <?php
  2. namespace App\Models\HtpmsCustomer;
  3. use Illuminate\Support\Facades\DB;
  4. class HtpmsCustomerConnectionSwitch
  5. {
  6. public static function switch(int $customerId): void
  7. {
  8. $connectionsRoot = "database.connections";
  9. $connectionHtmsCustomer = "htpms_customer";
  10. $databaseNameKey = "{$connectionsRoot}.{$connectionHtmsCustomer}.database";
  11. $currentDatabaseName = config($databaseNameKey);
  12. $afterDatabaseName = "htpms_{$customerId}";
  13. if ($currentDatabaseName !== $afterDatabaseName) {
  14. $conf = [$databaseNameKey => $afterDatabaseName];
  15. config($conf);
  16. DB::reconnect($connectionHtmsCustomer);
  17. }
  18. }
  19. }