Ensure hosted platform always has a subdomain configured

This commit is contained in:
David Bomba 2024-01-14 14:26:31 +11:00
parent 2d953dff10
commit 78aebe6bf7

View File

@ -15,6 +15,7 @@ use App;
use App\Factory\ClientContactFactory;
use App\Factory\VendorContactFactory;
use App\Jobs\Company\CreateCompanyToken;
use App\Libraries\MultiDB;
use App\Models\Account;
use App\Models\BankTransaction;
use App\Models\Client;
@ -128,6 +129,7 @@ class CheckData extends Command
$this->checkUserState();
$this->checkContactEmailAndSendEmailStatus();
$this->checkPaymentCurrency();
$this->checkSubdomainsSet();
if (Ninja::isHosted()) {
$this->checkAccountStatuses();
@ -1019,6 +1021,23 @@ class CheckData extends Command
}
}
public function checkSubdomainsSet()
{
if(Ninja::isSelfHost())
return;
Company::query()
->whereNull('subdomain')
->orWhere('subdomain', '')
->cursor()
->each(function ($c){
$c->subdomain = MultiDB::randomSubdomainGenerator();
$c->save();
});
}
public function checkPaymentCurrency()
{
$p = Payment::with('company','client')