46 lines
1.1 KiB
PHP
46 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace app\model;
|
|
|
|
use app\model\Base;
|
|
/**
|
|
* @property integer $id 主键(ID) - 无注释
|
|
* @property integer $user_id 用户ID
|
|
* @property string $content_type 内容类型 enum('text', 'image', 'file', 'video', 'link')
|
|
* @property string $content 收藏内容本体
|
|
* @property array $tags 用户自定义标签
|
|
* @property bool $is_pinned 是否置顶
|
|
* @property integer $status 状态
|
|
* @property integer $created_at 创建时间
|
|
* @property integer $updated_at 更新时间
|
|
*/
|
|
class Collection extends Base
|
|
{
|
|
|
|
public function user()
|
|
{
|
|
return $this->belongsTo('User', 'user_id', 'id');//->setEagerlyType(0);
|
|
}
|
|
public function setTagsAttr($v)
|
|
{
|
|
if(is_array($v)){
|
|
return implode(',',$v);
|
|
}
|
|
return $v;
|
|
}
|
|
public function getTagsAttr($v)
|
|
{
|
|
if($v && is_string($v)){
|
|
return explode(',',$v);
|
|
}
|
|
return null;
|
|
}
|
|
function getStatusList(){
|
|
return [
|
|
'0' => '兑换中',
|
|
'1' => '成功',
|
|
'-1' => '失败',
|
|
];
|
|
}
|
|
}
|