<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class SiteSetting extends Model
{
    use HasFactory;

    protected $fillable = [
        'site_name',
        'currency'
    ];

    /**
     * Get the site settings (singleton pattern)
     */
    public static function getSettings()
    {
        $settings = self::first();
        
        if (!$settings) {
            $settings = self::create([
                'site_name' => 'Hotel Management System',
                'currency' => 'USD'
            ]);
        }
        
        return $settings;
    }

    /**
     * Get site name
     */
    public static function getSiteName()
    {
        return self::getSettings()->site_name;
    }

    /**
     * Get currency
     */
    public static function getCurrency()
    {
        return self::getSettings()->currency;
    }
}

