merge product controller with kashkool
This commit is contained in:
@@ -6,14 +6,27 @@ use App\Models\Setting;
|
||||
|
||||
class ConfigService
|
||||
{
|
||||
public function Config($name)
|
||||
public function Config($name, $default = false)
|
||||
{
|
||||
return Setting::where('key', $name)->value('value') ?? false;
|
||||
$value = Setting::where('key', $name)->value('value');
|
||||
|
||||
return $value !== null ? $value : $default;
|
||||
}
|
||||
|
||||
public function ConfigBool(string $name, bool $default = false): bool
|
||||
{
|
||||
$value = $this->Config($name, null);
|
||||
|
||||
if ($value === null) {
|
||||
return $default;
|
||||
}
|
||||
|
||||
return in_array(strtolower(trim((string) $value)), ['1', 'true', 'yes', 'on'], true);
|
||||
}
|
||||
|
||||
public function UpdateConfig($name, $value)
|
||||
{
|
||||
return \App\Models\Setting::updateOrCreate(
|
||||
return Setting::updateOrCreate(
|
||||
['key' => $name],
|
||||
['value' => $value]
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user