added company model boot function try catch..
This commit is contained in:
parent
2fa5b599a2
commit
48fb23bb50
@ -286,57 +286,65 @@ class Company extends Eloquent implements Ownable
|
|||||||
|
|
||||||
public function setCommonSettingsAsAttributes()
|
public function setCommonSettingsAsAttributes()
|
||||||
{
|
{
|
||||||
$settings = $this->settings;
|
try { // TODO will optimize..
|
||||||
|
$settings = $this->settings;
|
||||||
|
|
||||||
$groups = [
|
$groups = [
|
||||||
'company',
|
'company',
|
||||||
'default',
|
'default',
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($settings as $setting) {
|
foreach ($settings as $setting) {
|
||||||
list($group, $key) = explode('.', $setting->getAttribute('key'));
|
list($group, $key) = explode('.', $setting->getAttribute('key'));
|
||||||
|
|
||||||
// Load only general settings
|
// Load only general settings
|
||||||
if (!in_array($group, $groups)) {
|
if (!in_array($group, $groups)) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$value = $setting->getAttribute('value');
|
||||||
|
|
||||||
|
if (($key == 'logo') && empty($value)) {
|
||||||
|
$value = 'public/img/company.png';
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->setAttribute($key, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
$value = $setting->getAttribute('value');
|
// Set default default company logo if empty
|
||||||
|
if ($this->getAttribute('logo') == '') {
|
||||||
if (($key == 'logo') && empty($value)) {
|
$this->setAttribute('logo', 'public/img/company.png');
|
||||||
$value = 'public/img/company.png';
|
|
||||||
}
|
}
|
||||||
|
} catch(\Throwable $e) {
|
||||||
$this->setAttribute($key, $value);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set default default company logo if empty
|
|
||||||
if ($this->getAttribute('logo') == '') {
|
|
||||||
$this->setAttribute('logo', 'public/img/company.png');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function unsetCommonSettingsFromAttributes()
|
public function unsetCommonSettingsFromAttributes()
|
||||||
{
|
{
|
||||||
$settings = $this->settings;
|
try { // TODO will optimize..
|
||||||
|
$settings = $this->settings;
|
||||||
|
|
||||||
$groups = [
|
$groups = [
|
||||||
'company',
|
'company',
|
||||||
'default',
|
'default',
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($settings as $setting) {
|
foreach ($settings as $setting) {
|
||||||
list($group, $key) = explode('.', $setting->getAttribute('key'));
|
list($group, $key) = explode('.', $setting->getAttribute('key'));
|
||||||
|
|
||||||
// Load only general settings
|
// Load only general settings
|
||||||
if (!in_array($group, $groups)) {
|
if (!in_array($group, $groups)) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->offsetUnset($key);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->offsetUnset($key);
|
$this->offsetUnset('logo');
|
||||||
|
} catch(\Throwable $e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->offsetUnset('logo');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user