<?php

if (!function_exists('get_setting')) {
    /**
     * Get system setting by key
     * 
     * @param string $key
     * @param string $default
     * @return string
     */
    function get_setting($key, $default = '')
    {
        $db = \Config\Database::connect();
        $setting = $db->table('settings')->where('key', $key)->get()->getRowArray();
        return $setting ? $setting['value'] : $default;
    }
}
