commit | author | age
|
2207d6
|
1 |
<?php |
W |
2 |
|
|
3 |
namespace app\models; |
|
4 |
|
|
5 |
use Yii; |
|
6 |
|
|
7 |
/** |
|
8 |
* This is the model class for table "{{%topic}}". |
|
9 |
* |
|
10 |
* @property int $id |
|
11 |
* @property int $mall_id |
|
12 |
* @property int $type |
|
13 |
* @property string $title 名称 |
|
14 |
* @property string $sub_title 副标题 |
|
15 |
* @property string $content 专题内容 |
|
16 |
* @property int $layout 布局方式:0=小图,1=大图模式 |
|
17 |
* @property int $sort 排序:升序 |
|
18 |
* @property int $cover_pic |
|
19 |
* @property int $read_count 阅读量 |
|
20 |
* @property int $agree_count 点赞数 |
|
21 |
* @property int $virtual_read_count 虚拟阅读量 |
|
22 |
* @property int $virtual_agree_count 虚拟点赞数 |
|
23 |
* @property int $virtual_favorite_count 虚拟收藏量 |
|
24 |
* @property int $is_chosen |
|
25 |
* @property int $is_delete |
|
26 |
* @property string $deleted_at |
|
27 |
* @property string $created_at |
|
28 |
* @property string $updated_at |
|
29 |
* @property int $qrcode_pic 自定义分享图片 |
|
30 |
* @property int $app_share_title 自定义分享标题 |
|
31 |
* @property string $pic_list |
|
32 |
* @property string $detail |
|
33 |
* @property string $abstract 摘要 |
|
34 |
* @property TopicType $topicType |
|
35 |
* @property TopicFavorite $favorite |
|
36 |
*/ |
|
37 |
class Topic extends ModelActiveRecord |
|
38 |
{ |
|
39 |
/** |
|
40 |
* {@inheritdoc} |
|
41 |
*/ |
|
42 |
public static function tableName() |
|
43 |
{ |
|
44 |
return '{{%topic}}'; |
|
45 |
} |
|
46 |
|
|
47 |
/** |
|
48 |
* {@inheritdoc} |
|
49 |
*/ |
|
50 |
public function rules() |
|
51 |
{ |
|
52 |
return [ |
|
53 |
[['mall_id', 'type', 'title', 'content', 'cover_pic', 'deleted_at', 'created_at', 'updated_at'], 'required'], |
|
54 |
[['mall_id', 'type', 'layout', 'sort', 'read_count', 'agree_count', 'virtual_read_count', 'virtual_agree_count', 'virtual_favorite_count', 'is_chosen', 'is_delete'], 'integer'], |
|
55 |
[['content', 'pic_list', 'detail'], 'string'], |
|
56 |
[['deleted_at', 'created_at', 'updated_at'], 'safe'], |
|
57 |
[['title', 'sub_title', 'cover_pic', 'qrcode_pic', 'abstract'], 'string', 'max' => 255], |
|
58 |
[['app_share_title'], 'string', 'max' => 65], |
|
59 |
]; |
|
60 |
} |
|
61 |
|
|
62 |
/** |
|
63 |
* {@inheritdoc} |
|
64 |
*/ |
|
65 |
public function attributeLabels() |
|
66 |
{ |
|
67 |
return [ |
|
68 |
'id' => 'ID', |
|
69 |
'mall_id' => 'mall ID', |
|
70 |
'type' => '分类', |
|
71 |
'title' => '名称', |
|
72 |
'sub_title' => '副标题(未用)', |
|
73 |
'content' => '专题内容', |
|
74 |
'layout' => '布局方式:0=小图,1=大图模式', |
|
75 |
'sort' => '排序:升序', |
|
76 |
'cover_pic' => '封面图', |
|
77 |
'read_count' => '阅读量', |
|
78 |
'agree_count' => '点赞数(未用)', |
|
79 |
'virtual_read_count' => '虚拟阅读量', |
|
80 |
'virtual_agree_count' => '虚拟点赞数(未用)', |
|
81 |
'virtual_favorite_count' => '虚拟收藏量', |
|
82 |
'qrcode_pic' => '自定义分享图片', |
|
83 |
'is_chosen' => '是否精选', |
|
84 |
'is_delete' => '删除', |
|
85 |
'app_share_title' => '自定义分享标题', |
|
86 |
'deleted_at' => 'Deleted At', |
|
87 |
'created_at' => 'Created At', |
|
88 |
'updated_at' => 'Updated At', |
|
89 |
'pic_list' => '多图模式 图片列表', |
|
90 |
'detail' => '新版专题详情', |
|
91 |
'abstract' => '摘要', |
|
92 |
]; |
|
93 |
} |
|
94 |
|
|
95 |
public function getTopicType() |
|
96 |
{ |
|
97 |
return $this->hasOne(TopicType::className(), ['id' => 'type']); |
|
98 |
} |
|
99 |
|
|
100 |
public function getFavorite() |
|
101 |
{ |
|
102 |
return $this->hasOne(TopicFavorite::className(), ['topic_id' => 'id']); |
|
103 |
} |
|
104 |
} |