| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 | 
							- <?php
 
- namespace app\common\model;
 
- class SettingModel extends BaseModel
 
- {
 
-     // 设置表名
 
-     protected $table = 'setting';
 
-     // 短信配置
 
-     const SMS = [
 
-         'sms_chuanglan_appkey',
 
-         'sms_chuanglan_secret',
 
-     ];
 
-     const SYSTEM = [
 
-         'site_name',
 
-     ];
 
-     public static function getConfigValue($code)
 
-     {
 
-         $res = [];
 
-         if (is_array($code)) {
 
-             $list = self::where('code', 'in', $code)->select();
 
-             if ($list->isEmpty()) {
 
-                 return [];
 
-             }
 
-             foreach ($list as $v) {
 
-                 $res[$v['code']] = $v['value'];
 
-             }
 
-         } elseif (is_string($code)) {
 
-             $info = self::where('code', $code)->find();
 
-             if (empty($info)) {
 
-                 return '';
 
-             }
 
-             $res  = $info['value'];
 
-         }
 
-         return $res;
 
-     }
 
-     public static function setConfigValue($code, $value = '')
 
-     {
 
-         if (is_array($code)) {
 
-             foreach ($code as $k => $v) {
 
-                 self::setConfigValueSingle($k, $v);
 
-             }
 
-         } elseif (is_string($code)) {
 
-             self::setConfigValueSingle($code, $value);
 
-         }
 
-     }
 
-     public static function setConfigValueSingle($code, $value = '')
 
-     {
 
-         $info = self::where('code', $code)->find();
 
-         if (empty($info)) {
 
-             self::create(['code' => $code, 'value' => $value]);
 
-         } else {
 
-             $info->value = $value;
 
-             $info->save();
 
-         }
 
-     }
 
- }
 
 
  |