123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <?php
- namespace app\common\model;
- class Config extends Base
- {
- const CODE_WECHAT = 'wechat';
-
- protected $json = ['content'];
-
- public static function getConfig($code)
- {
- $config = (new self)->where('code', $code)->cache(true, 60)->find();
- if (empty($config)) {
- $configData = [
- 'code' => $code,
- 'create_time' => getNow(),
- 'update_time' => getNow(),
- ];
- $config = self::create($configData);
- }
- return $config;
- }
-
- public static function getConfigContent($code)
- {
- $config = self::getConfig($code);
- return $config->content;
- }
-
- public static function getConfigValue($code, $content_code = '')
- {
- $content = self::getConfigContent($code);
- return $content->$content_code;
- }
- }
|