From 80d033b952b9bffc65f935bde90bce33f75c146e Mon Sep 17 00:00:00 2001 From: = Date: Fri, 25 Jun 2021 19:56:36 +1000 Subject: [PATCH 1/2] Minor fixes for subdomain filling --- app/Console/Commands/SubdomainFill.php | 40 +++++++++++++------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/app/Console/Commands/SubdomainFill.php b/app/Console/Commands/SubdomainFill.php index fa4e7110f3b0..afa2624ae0e3 100644 --- a/app/Console/Commands/SubdomainFill.php +++ b/app/Console/Commands/SubdomainFill.php @@ -60,36 +60,36 @@ class SubdomainFill extends Command }); - $db1 = Company::on('db-ninja-01')->get(); + // $db1 = Company::on('db-ninja-01')->get(); - $db1->each(function ($company){ + // $db1->each(function ($company){ - $db2 = Company::on('db-ninja-02a')->find($company->id); + // $db2 = Company::on('db-ninja-02a')->find($company->id); - if($db2) - { - $db2->subdomain = $company->subdomain; - $db2->save(); - } + // if($db2) + // { + // $db2->subdomain = $company->subdomain; + // $db2->save(); + // } - }); + // }); - $db1 = null; - $db2 = null; + // $db1 = null; + // $db2 = null; - $db2 = Company::on('db-ninja-02')->get(); + // $db2 = Company::on('db-ninja-02')->get(); - $db2->each(function ($company){ + // $db2->each(function ($company){ - $db1 = Company::on('db-ninja-01a')->find($company->id); + // $db1 = Company::on('db-ninja-01a')->find($company->id); - if($db1) - { - $db1->subdomain = $company->subdomain; - $db1->save(); - } - }); + // if($db1) + // { + // $db1->subdomain = $company->subdomain; + // $db1->save(); + // } + // }); } } From eaebaccdaf7e4f1e8afc443a94b73f979c1a851c Mon Sep 17 00:00:00 2001 From: = Date: Fri, 25 Jun 2021 19:58:35 +1000 Subject: [PATCH 2/2] Catch all for null subdomains --- app/Jobs/Util/Import.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/Jobs/Util/Import.php b/app/Jobs/Util/Import.php index 4f45ba9a5959..e4bf9466ee8c 100644 --- a/app/Jobs/Util/Import.php +++ b/app/Jobs/Util/Import.php @@ -337,6 +337,10 @@ class Import implements ShouldQueue if(!MultiDB::checkDomainAvailable($data['subdomain'])) $data['subdomain'] = MultiDB::randomSubdomainGenerator(); + + if(strlen($data['subdomain']) == 0) + $data['subdomain'] = MultiDB::randomSubdomainGenerator(); + } $rules = (new UpdateCompanyRequest())->rules();