forked from kuafuRace/phprap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfig.php
More file actions
executable file
·60 lines (52 loc) · 1.13 KB
/
Config.php
File metadata and controls
executable file
·60 lines (52 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
namespace app\models;
use Yii;
/**
* This is the model class for table "doc_config".
*
* @property int $id
* @property string $type 配置类型
* @property string $content 配置内容
* @property string $created_at
* @property string $updated_at
*/
class Config extends Model
{
/**
* 绑定数据表
*/
public static function tableName()
{
return '{{%config}}';
}
/**
* 验证规则
*/
public function rules()
{
return [
[['type', 'content'], 'required'],
[['content'], 'string'],
[['created_at', 'updated_at'], 'safe'],
[['type'], 'string', 'max' => 10],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'type' => 'Type',
'content' => 'Content',
'created_at' => 'Created At',
'updated_at' => 'Updated At',
];
}
public function getField($field = null)
{
$config = json_decode($this->content);
return $field ? trim($config->$field) : $config;
}
}