added company model boot function try catch..

This commit is contained in:
Cüneyt Şentürk 2022-03-02 18:00:31 +03:00
parent 2fa5b599a2
commit 48fb23bb50

View File

@ -286,57 +286,65 @@ class Company extends Eloquent implements Ownable
public function setCommonSettingsAsAttributes()
{
$settings = $this->settings;
try { // TODO will optimize..
$settings = $this->settings;
$groups = [
'company',
'default',
];
$groups = [
'company',
'default',
];
foreach ($settings as $setting) {
list($group, $key) = explode('.', $setting->getAttribute('key'));
foreach ($settings as $setting) {
list($group, $key) = explode('.', $setting->getAttribute('key'));
// Load only general settings
if (!in_array($group, $groups)) {
continue;
// Load only general settings
if (!in_array($group, $groups)) {
continue;
}
$value = $setting->getAttribute('value');
if (($key == 'logo') && empty($value)) {
$value = 'public/img/company.png';
}
$this->setAttribute($key, $value);
}
$value = $setting->getAttribute('value');
if (($key == 'logo') && empty($value)) {
$value = 'public/img/company.png';
// Set default default company logo if empty
if ($this->getAttribute('logo') == '') {
$this->setAttribute('logo', 'public/img/company.png');
}
$this->setAttribute($key, $value);
}
// Set default default company logo if empty
if ($this->getAttribute('logo') == '') {
$this->setAttribute('logo', 'public/img/company.png');
} catch(\Throwable $e) {
}
}
public function unsetCommonSettingsFromAttributes()
{
$settings = $this->settings;
try { // TODO will optimize..
$settings = $this->settings;
$groups = [
'company',
'default',
];
$groups = [
'company',
'default',
];
foreach ($settings as $setting) {
list($group, $key) = explode('.', $setting->getAttribute('key'));
foreach ($settings as $setting) {
list($group, $key) = explode('.', $setting->getAttribute('key'));
// Load only general settings
if (!in_array($group, $groups)) {
continue;
// Load only general settings
if (!in_array($group, $groups)) {
continue;
}
$this->offsetUnset($key);
}
$this->offsetUnset($key);
$this->offsetUnset('logo');
} catch(\Throwable $e) {
}
$this->offsetUnset('logo');
}
/**