123456789101112131415161718192021222324252627282930313233 |
- <?php
- namespace app\common\model;
- use think\Model;
- class ArticleCollect extends Model
- {
- // 设置字段信息
- protected $schema = [
- 'id' => 'int',
- 'userid' => 'int',
- 'articleid' => 'int',
- 'createtime' => 'int'
- ];
-
- // 设置字段自动转换类型
- protected $type = [
- 'createtime' => 'timestamp:Y-m-d H:i:s'
- ];
-
- // 关联Article
- public function article()
- {
- return $this->hasOne(Article::class, "id", "articleid");
- }
-
- // 关联User
- public function user()
- {
- return $this->hasOne(User::class, "id", "userid");
- }
- }
|