Fixes for type checks

This commit is contained in:
David Bomba 2022-04-21 16:04:59 +10:00
parent ebc498a815
commit 70c5f268ed
2 changed files with 16 additions and 5 deletions

View File

@ -125,7 +125,7 @@ class TypeCheck extends Command
{ {
$this->logMessage(date('Y-m-d h:i:s').' Checking Company => ' . $company->present()->name(). " " . $company->id); $this->logMessage(date('Y-m-d h:i:s').' Checking Company => ' . $company->present()->name(). " " . $company->id);
$company->saveSettings($company->settings, $company); $company->saveSettings((array)$company->settings, $company);
} }
@ -135,7 +135,7 @@ class TypeCheck extends Command
$this->logMessage(date('Y-m-d h:i:s').' Checking all clients and companies.'); $this->logMessage(date('Y-m-d h:i:s').' Checking all clients and companies.');
Client::cursor()->each( function ($client) { Client::cursor()->each( function ($client) {
$this->logMessage("Checking client {$client->id}");
$entity_settings = $this->checkSettingType($client->settings); $entity_settings = $this->checkSettingType($client->settings);
$entity_settings->md5 = md5(time()); $entity_settings->md5 = md5(time());
$client->settings = $entity_settings; $client->settings = $entity_settings;
@ -144,7 +144,7 @@ class TypeCheck extends Command
}); });
Company::cursor()->each( function ($company) { Company::cursor()->each( function ($company) {
$this->logMessage("Checking company {$company->id}");
$company->saveSettings($company->settings, $company); $company->saveSettings($company->settings, $company);
}); });

View File

@ -63,10 +63,21 @@ trait CompanySettingsSaver
{ {
//this pass will handle any null values that are in the translations //this pass will handle any null values that are in the translations
foreach ($settings->translations as $key => $value) { foreach ($settings->translations as $key => $value) {
if(is_array($settings->translations))
{
if (is_null($settings->translations[$key])) { if (is_null($settings->translations[$key])) {
$settings->translations[$key] = ''; $settings->translations[$key] = '';
} }
} }
elseif(is_object($settings->translations)){
if (is_null($settings->translations->{$key})) {
$settings->translations->{$key} = '';
}
}
}
$company_settings->translations = $settings->translations; $company_settings->translations = $settings->translations;
} }