Akaunting/app/Traits/Settings.php

31 lines
598 B
PHP
Raw Permalink Normal View History

2023-10-26 20:16:08 +00:00
<?php
namespace App\Traits;
use App\Models\Setting\Setting;
use App\Traits\Companies;
trait Settings
{
use Companies;
2023-10-26 20:59:06 +00:00
public function getSettingValue(string $key, mixed $default = null): mixed
2023-10-26 20:16:08 +00:00
{
$settings = setting()->all();
if (! empty($settings)) {
2023-10-26 20:59:06 +00:00
return setting($key, $default);
2023-10-26 20:16:08 +00:00
}
$company_id = $this->getCompanyId();
if (empty($company_id)) {
return $default;
}
2023-10-26 20:59:06 +00:00
$value = Setting::companyId($company_id)->where('key', $key)->pluck('value')->first();
return $value ?: $default;
2023-10-26 20:16:08 +00:00
}
}