Skip to content

Commit

Permalink
fixed default return
Browse files Browse the repository at this point in the history
  • Loading branch information
denisdulici committed Oct 26, 2023
1 parent 252ff28 commit c60e250
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions app/Traits/Settings.php
Expand Up @@ -9,12 +9,12 @@ trait Settings
{
use Companies;

public function getSettingValue(string $key, mixed $default = ''): mixed
public function getSettingValue(string $key, mixed $default = null): mixed
{
$settings = setting()->all();

if (! empty($settings)) {
return setting($key);
return setting($key, $default);
}

$company_id = $this->getCompanyId();
Expand All @@ -23,6 +23,8 @@ public function getSettingValue(string $key, mixed $default = ''): mixed
return $default;
}

return Setting::companyId($company_id)->where('key', $key)->pluck('value')->first();
$value = Setting::companyId($company_id)->where('key', $key)->pluck('value')->first();

return $value ?: $default;
}
}
2 changes: 1 addition & 1 deletion app/Utilities/Info.php
Expand Up @@ -93,6 +93,6 @@ public static function getApiKey(): string
{
$setting = new class() { use Settings; };

return $setting->getSettingValue('apps.api_key');
return $setting->getSettingValue('apps.api_key', '');
}
}

0 comments on commit c60e250

Please sign in to comment.