You've already forked Atomcms-edit
24 lines
621 B
PHP
Executable File
24 lines
621 B
PHP
Executable File
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Http\Controllers\Concerns;
|
|
|
|
use App\Enums\RadioSettings;
|
|
use App\Models\Miscellaneous\WebsiteSetting;
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
|
trait HasRadioSettings
|
|
{
|
|
private function getSetting(RadioSettings|string $key, mixed $default = null): mixed
|
|
{
|
|
$keyStr = $key instanceof RadioSettings ? $key->value : $key;
|
|
|
|
return Cache::remember("setting_{$keyStr}", 60, function () use ($keyStr, $default): mixed {
|
|
$setting = WebsiteSetting::where('key', $keyStr)->first();
|
|
|
|
return $setting?->value ?? $default;
|
|
});
|
|
}
|
|
}
|