feat: add system configuration (A-03) — map center, zoom, radius min/max
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
class Setting extends Model
|
||||
{
|
||||
protected $fillable = ['key', 'value', 'label'];
|
||||
|
||||
public static function getAll(): array
|
||||
{
|
||||
return Cache::remember('app_settings', 300, function () {
|
||||
return static::pluck('value', 'key')->toArray();
|
||||
});
|
||||
}
|
||||
|
||||
public static function get(string $key, mixed $default = null): mixed
|
||||
{
|
||||
return static::getAll()[$key] ?? $default;
|
||||
}
|
||||
|
||||
public static function set(string $key, string $value): void
|
||||
{
|
||||
static::where('key', $key)->update(['value' => $value]);
|
||||
Cache::forget('app_settings');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user