<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Setting extends Model
{
    protected $fillable = ['key', 'value'];

    /**
     * Mengambil nilai pengaturan berdasarkan key.
     * Contoh: Setting::get('shop_name')
     */
    public static function get($key, $default = null)
    {
        $setting = self::where('key', $key)->first();
        return $setting ? $setting->value : $default;
    }

    /**
     * Alias untuk backward compatibility.
     * @deprecated Gunakan Setting::get() sebagai gantinya.
     */
    public static function set($key, $default = null)
    {
        return self::get($key, $default);
    }
}